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 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ 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); } static inline struct rtrs_srv *__find_srv_and_get(struct rtrs_srv_ctx *ctx, -- 2.25.1