Skip to content

Commit 39c2d63

Browse files
Md Haris Iqbaljgunthorpe
authored andcommitted
RDMA/rtrs-srv: Set .release function for rtrs srv device during device init
The device .release function was not being set during the device initialization. This was leading to the below warning, in error cases when put_srv was called before device_add was called. Warning: Device '(null)' does not have a release() function, it is broken and must be fixed. See Documentation/kobject.txt. So, set the device .release function during device initialization in the __alloc_srv() function. Fixes: baa5b28 ("RDMA/rtrs-srv: Replace device_register with device_initialize and device_add") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Md Haris Iqbal <[email protected]> Reviewed-by: Leon Romanovsky <[email protected]> Acked-by: Jack Wang <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 9e71244 commit 39c2d63

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@ static struct attribute_group rtrs_srv_stats_attr_group = {
152152
.attrs = rtrs_srv_stats_attrs,
153153
};
154154

155-
static void rtrs_srv_dev_release(struct device *dev)
156-
{
157-
struct rtrs_srv *srv = container_of(dev, struct rtrs_srv, dev);
158-
159-
kfree(srv);
160-
}
161-
162155
static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess)
163156
{
164157
struct rtrs_srv *srv = sess->srv;
@@ -172,7 +165,6 @@ static int rtrs_srv_create_once_sysfs_root_folders(struct rtrs_srv_sess *sess)
172165
goto unlock;
173166
}
174167
srv->dev.class = rtrs_dev_class;
175-
srv->dev.release = rtrs_srv_dev_release;
176168
err = dev_set_name(&srv->dev, "%s", sess->s.sessname);
177169
if (err)
178170
goto unlock;

drivers/infiniband/ulp/rtrs/rtrs-srv.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,13 @@ static int rtrs_srv_get_next_cq_vector(struct rtrs_srv_sess *sess)
13191319
return sess->cur_cq_vector;
13201320
}
13211321

1322+
static void rtrs_srv_dev_release(struct device *dev)
1323+
{
1324+
struct rtrs_srv *srv = container_of(dev, struct rtrs_srv, dev);
1325+
1326+
kfree(srv);
1327+
}
1328+
13221329
static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx,
13231330
const uuid_t *paths_uuid)
13241331
{
@@ -1337,6 +1344,7 @@ static struct rtrs_srv *__alloc_srv(struct rtrs_srv_ctx *ctx,
13371344
srv->queue_depth = sess_queue_depth;
13381345
srv->ctx = ctx;
13391346
device_initialize(&srv->dev);
1347+
srv->dev.release = rtrs_srv_dev_release;
13401348

13411349
srv->chunks = kcalloc(srv->queue_depth, sizeof(*srv->chunks),
13421350
GFP_KERNEL);

0 commit comments

Comments
 (0)