Re: [PATCH for-rc] RDMA/qder: Fix memory leak of iwcm pointer

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

 



On Mon, Apr 22, 2019 at 05:00:19PM +0300, Kamal Heib wrote:
> Make sure to release the iwcm pointer that is allocated in
> qedr_iw_register_device() but never released.
> 
> Fixes: e6a38c54faf3 ("RDMA/qedr: Add support for registering an iWARP device")
> Signed-off-by: Kamal Heib <kamalheib1@xxxxxxxxx>
>  drivers/infiniband/hw/qedr/main.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c
> index 996d9ecd93e0..567f55178379 100644
> +++ b/drivers/infiniband/hw/qedr/main.c
> @@ -293,7 +293,13 @@ static int qedr_register_device(struct qedr_dev *dev)
>  	ib_set_device_ops(&dev->ibdev, &qedr_dev_ops);
>  
>  	dev->ibdev.driver_id = RDMA_DRIVER_QEDR;
> -	return ib_register_device(&dev->ibdev, "qedr%d");
> +	rc = ib_register_device(&dev->ibdev, "qedr%d");
> +	if (rc) {
> +		if (IS_IWARP(dev))
> +			kfree(dev->ibdev.iwcm);
> +	}
> +
> +	return rc;
>  }
>  
>  /* This function allocates fast-path status block memory */
> @@ -937,6 +943,8 @@ static void qedr_remove(struct qedr_dev *dev)
>  	 * of the registered clients.
>  	 */
>  	ib_unregister_device(&dev->ibdev);
> +	if (IS_IWARP(dev))
> +		kfree(dev->ibdev.iwcm);

This should probably just be in a dealloc_driver callback instead of
duplicated

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux