• Wen Yang's avatar
    pvcalls-front: fix potential null dereference · b4711098
    Wen Yang authored
     static checker warning:
        drivers/xen/pvcalls-front.c:373 alloc_active_ring()
        error: we previously assumed 'map->active.ring' could be null
               (see line 357)
    
    drivers/xen/pvcalls-front.c
        351 static int alloc_active_ring(struct sock_mapping *map)
        352 {
        353     void *bytes;
        354
        355     map->active.ring = (struct pvcalls_data_intf *)
        356         get_zeroed_page(GFP_KERNEL);
        357     if (!map->active.ring)
                        ^^^^^^^^^^^^^^^^^
    Check
    
        358         goto out;
        359
        360     map->active.ring->ring_order = PVCALLS_RING_ORDER;
        361     bytes = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
        362                     PVCALLS_RING_ORDER);
        363     if (!bytes)
        364         goto out;
        365
        366     map->active.data.in = bytes;
        367     map->active.data.out = bytes +
        368         XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER);
        369
        370     return 0;
        371
        372 out:
    --> 373     free_active_ring(map);
                                     ^^^
    Add null check on map->active.ring before dereferencing it to avoid
    any NULL pointer dereferences.
    
    Fixes: 9f51c05d ("pvcalls-front: Avoid get_free_pages(GFP_KERNEL) under spinlock")
    Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
    Suggested-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
    Signed-off-by: default avatarWen Yang <wen.yang99@zte.com.cn>
    Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
    CC: Boris Ostrovsky <boris.ostrovsky@oracle.com>
    CC: Juergen Gross <jgross@suse.com>
    CC: Stefano Stabellini <sstabellini@kernel.org>
    CC: Dan Carpenter <dan.carpenter@oracle.com>
    CC: xen-devel@lists.xenproject.org
    CC: linux-kernel@vger.kernel.org
    Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
    b4711098
Name
Last commit
Last update
..
events Loading commit data...
xen-pciback Loading commit data...
xenbus Loading commit data...
xenfs Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
acpi.c Loading commit data...
arm-device.c Loading commit data...
balloon.c Loading commit data...
biomerge.c Loading commit data...
cpu_hotplug.c Loading commit data...
dbgp.c Loading commit data...
efi.c Loading commit data...
evtchn.c Loading commit data...
fallback.c Loading commit data...
features.c Loading commit data...
gntalloc.c Loading commit data...
gntdev-common.h Loading commit data...
gntdev-dmabuf.c Loading commit data...
gntdev-dmabuf.h Loading commit data...
gntdev.c Loading commit data...
grant-table.c Loading commit data...
manage.c Loading commit data...
mcelog.c Loading commit data...
mem-reservation.c Loading commit data...
pci.c Loading commit data...
pcpu.c Loading commit data...
platform-pci.c Loading commit data...
preempt.c Loading commit data...
privcmd-buf.c Loading commit data...
privcmd.c Loading commit data...
privcmd.h Loading commit data...
pvcalls-back.c Loading commit data...
pvcalls-front.c Loading commit data...
pvcalls-front.h Loading commit data...
swiotlb-xen.c Loading commit data...
sys-hypervisor.c Loading commit data...
time.c Loading commit data...
tmem.c Loading commit data...
xen-acpi-cpuhotplug.c Loading commit data...
xen-acpi-memhotplug.c Loading commit data...
xen-acpi-pad.c Loading commit data...
xen-acpi-processor.c Loading commit data...
xen-balloon.c Loading commit data...
xen-front-pgdir-shbuf.c Loading commit data...
xen-scsiback.c Loading commit data...
xen-selfballoon.c Loading commit data...
xen-stub.c Loading commit data...
xlate_mmu.c Loading commit data...