mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
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>
This commit is contained in:
1 parent
d693b22733
commit
d778089ac7
1 file changed
+1
-1
@@ -859,7 +859,7 @@ static int name2bdf(libxl__gc *gc, libxl_device_pci *pci)
|
|||||||
int rc = ERROR_NOTFOUND;
|
int rc = ERROR_NOTFOUND;
|
||||||
|
|
||||||
bdfs = libxl__xs_directory(gc, XBT_NULL, PCI_INFO_PATH, &n);
|
bdfs = libxl__xs_directory(gc, XBT_NULL, PCI_INFO_PATH, &n);
|
||||||
if (!n)
|
if (!bdfs || !n)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
|||||||