Re: [PATCH 2/3] RDMA/rtrs-srv: only call put_device when it's in sysfs

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

 



On Fri, Jul 24, 2020 at 04:45:07PM +0530, Md Haris Iqbal wrote:
> From: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx>
> 
> There are error case we will call free_srv before device kobject
> initialized, in such case we shouldn't call put_device, otherwise
> a Warning will be generated, eg:
> 
> kobject: '(null)' (000000009f5445ed): is not initialized, yet kobject_put() is being called.
> 
> So add check before call into put_device.
> 
> Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
> Signed-off-by: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx>
> Signed-off-by: Md Haris Iqbal <haris.iqbal@xxxxxxxxxxxxxxx>
>  drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> index 0d9241f5d9e6..8a55bc559466 100644
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
> @@ -1373,7 +1373,10 @@ static void free_srv(struct rtrs_srv *srv)
>  	mutex_destroy(&srv->paths_mutex);
>  	mutex_destroy(&srv->paths_ev_mutex);
>  	/* last put to release the srv structure */
> -	put_device(&srv->dev);
> +	if(srv->dev.kobj.state_in_sysfs)
> +		put_device(&srv->dev);
> +	else
> +		kfree(srv);
>  }

Not like this, call device_initialize() sooner.

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