]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
ib_core: initialize shpd field when allocating 'struct ib_pd'
authorMukesh Kacker <mukesh.kacker@oracle.com>
Wed, 20 Feb 2019 19:10:04 +0000 (11:10 -0800)
committerBrian Maly <brian.maly@oracle.com>
Fri, 29 Mar 2019 19:33:48 +0000 (15:33 -0400)
The shared pd feature in Oracle Linux was added by
commit a1911c2c180d ("IB/Shared PD support from Oracle").
It adds a field named shpd to 'struct ib_pd' but fails to
initialize it in all the places it is allocated.

This results its uninitialized content being referenced
in mlx4_ib_dealloc_pd() and actions taken based on it
which eventually leads to resource leaks even when shared
pd feature is not being used.

This fix here initializes it to NULL in ib_alloc_pd() where
the ib_core module allocates the data structure.

Orabug: 29384815

Signed-off-by: Mukesh Kacker <mukesh.kacker@oracle.com>
Reviewed-by: Rama Nichanamatlu <rama.nichanamatlu@oracle.com>
Reviewed-by: HÃ¥kon Bugge <haakon.bugge@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/infiniband/core/verbs.c

index b48755ba561540f65eacc8cd4020cc186f618ebb..3da00c6532cf47127f910501c9786e40f791548e 100644 (file)
@@ -171,8 +171,10 @@ struct ib_pd *ib_alloc_pd(struct ib_device *device)
        pd = device->alloc_pd(device, NULL, NULL);
 
        if (!IS_ERR(pd)) {
+               /* init all fields of allocated object */
                pd->device  = device;
                pd->uobject = NULL;
+               pd->shpd = NULL;
                atomic_set(&pd->usecnt, 0);
        }