From: Mukesh Kacker Date: Wed, 20 Feb 2019 19:10:04 +0000 (-0800) Subject: ib_core: initialize shpd field when allocating 'struct ib_pd' X-Git-Tag: v4.1.12-124.31.3~212 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e7c19601874a83e2cbda63f8b5baad26d8bd93a2;p=users%2Fjedix%2Flinux-maple.git ib_core: initialize shpd field when allocating 'struct ib_pd' 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 Reviewed-by: Rama Nichanamatlu Reviewed-by: HÃ¥kon Bugge Signed-off-by: Brian Maly --- diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index b48755ba5615..3da00c6532cf 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -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); }