libxl: check return value of libxl__xs_directory in name2bdf
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 12 Jul 2022 09:16:30 +0000 (11:16 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Jul 2022 09:16:30 +0000 (11:16 +0200)
commit744accad1b73223b3261e3e678e16e030d83b179
tree8105cf057c3b059f68585e82954ab7c71f91adf6
parent14fd97e3de939a63a6e467f240efb49fe226a5dc
libxl: check return value of libxl__xs_directory in name2bdf

libxl__xs_directory() can potentially return NULL without setting `n`.
As `n` isn't initialised, we need to check libxl__xs_directory()
return value before checking `n`. Otherwise, `n` might be non-zero
with `bdfs` NULL which would lead to a segv.

Fixes: 57bff091f4 ("libxl: add 'name' field to 'libxl_device_pci' in the IDL...")
Reported-by: "G.R." <firemeteor@users.sourceforge.net>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Tested-by: "G.R." <firemeteor@users.sourceforge.net>
master commit: d778089ac70e5b8e3bdea0c85fc8c0b9ed0eaf2f
master date: 2022-07-12 08:38:51 +0200
tools/libs/light/libxl_pci.c