libxl: check return value of libxl__xs_directory in name2bdf
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 12 Jul 2022 06:38:51 +0000 (08:38 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 12 Jul 2022 06:38:51 +0000 (08:38 +0200)
commitd778089ac70e5b8e3bdea0c85fc8c0b9ed0eaf2f
treed6ef754908698b5b65a5bf3ad3c30eb644b861b7
parentd693b22733044d68e9974766b5c9e6259c9b1708
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>
tools/libs/light/libxl_pci.c