On Fri, Jan 10, 2020 at 04:34:08PM +0100, Guoqing Jiang wrote: > Forget to cc list, sorry. > > On 1/10/20 4:32 PM, jgq516@xxxxxxxxx wrote: > > From: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> > > > > In add_one_compat_dev, if failure happens after cdev is allocated, > > so we need to free the memory accordingly. > > > > Fixes: 4e0f7b9070726 ("RDMA/core: Implement compat device/sysfs tree in net namespace") > > Cc: Parav Pandit <parav@xxxxxxxxxxxx> > > Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> > > Hi, > > > > When reading the code, it looks no place to free cdev under those err condition. > > And I guess remove_one_compat_dev needs to free cdev as well, something like: > > > > @@ -937,6 +937,8 @@ static void remove_one_compat_dev(struct ib_device *device, u32 id) > > ib_free_port_attrs(cdev); > > device_del(&cdev->dev); > > put_device(&cdev->dev); > > + kfree(cdev); > > + cdev = NULL; > > } > > } > > > > But since I am not know well about the code, so this is RFC. put_device triggers compatdev_release which does the free Jason