[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] libxl: check return value of libxl__xs_directory in name2bdf



commit d778089ac70e5b8e3bdea0c85fc8c0b9ed0eaf2f
Author:     Anthony PERARD <anthony.perard@xxxxxxxxxx>
AuthorDate: Tue Jul 12 08:38:51 2022 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jul 12 08:38:51 2022 +0200

    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@xxxxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
    Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
    Tested-by: "G.R." <firemeteor@xxxxxxxxxxxxxxxxxxxxx>
---
 tools/libs/light/libxl_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c
index 96f88795b6..f4c4f17545 100644
--- a/tools/libs/light/libxl_pci.c
+++ b/tools/libs/light/libxl_pci.c
@@ -859,7 +859,7 @@ static int name2bdf(libxl__gc *gc, libxl_device_pci *pci)
     int rc = ERROR_NOTFOUND;
 
     bdfs = libxl__xs_directory(gc, XBT_NULL, PCI_INFO_PATH, &n);
-    if (!n)
+    if (!bdfs || !n)
         goto out;
 
     for (i = 0; i < n; i++) {
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.