Commit 424774c9 authored by Guoqing Jiang's avatar Guoqing Jiang Committed by Jason Gunthorpe

RDMA/rtrs: Call kobject_put in the failure path

Per the comment of kobject_init_and_add, we need to free the memory
by call kobject_put.

Fixes: 215378b8 ("RDMA/rtrs: client: sysfs interface functions")
Fixes: 91b11610 ("RDMA/rtrs: server: sysfs interface functions")
Link: https://lore.kernel.org/r/20201217141915.56989-8-jinpu.wang@cloud.ionos.comSigned-off-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
Reviewed-by: default avatarMd Haris Iqbal <haris.iqbal@cloud.ionos.com>
Reviewed-by: default avatarGioh Kim <gi-oh.kim@cloud.ionos.com>
Signed-off-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent f77c4839
...@@ -408,6 +408,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess) ...@@ -408,6 +408,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess)
"%s", str); "%s", str);
if (err) { if (err) {
pr_err("kobject_init_and_add: %d\n", err); pr_err("kobject_init_and_add: %d\n", err);
kobject_put(&sess->kobj);
return err; return err;
} }
err = sysfs_create_group(&sess->kobj, &rtrs_clt_sess_attr_group); err = sysfs_create_group(&sess->kobj, &rtrs_clt_sess_attr_group);
...@@ -419,6 +420,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess) ...@@ -419,6 +420,7 @@ int rtrs_clt_create_sess_files(struct rtrs_clt_sess *sess)
&sess->kobj, "stats"); &sess->kobj, "stats");
if (err) { if (err) {
pr_err("kobject_init_and_add: %d\n", err); pr_err("kobject_init_and_add: %d\n", err);
kobject_put(&sess->stats->kobj_stats);
goto remove_group; goto remove_group;
} }
......
...@@ -236,6 +236,7 @@ static int rtrs_srv_create_stats_files(struct rtrs_srv_sess *sess) ...@@ -236,6 +236,7 @@ static int rtrs_srv_create_stats_files(struct rtrs_srv_sess *sess)
&sess->kobj, "stats"); &sess->kobj, "stats");
if (err) { if (err) {
rtrs_err(s, "kobject_init_and_add(): %d\n", err); rtrs_err(s, "kobject_init_and_add(): %d\n", err);
kobject_put(&sess->stats->kobj_stats);
return err; return err;
} }
err = sysfs_create_group(&sess->stats->kobj_stats, err = sysfs_create_group(&sess->stats->kobj_stats,
...@@ -292,8 +293,8 @@ int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess) ...@@ -292,8 +293,8 @@ int rtrs_srv_create_sess_files(struct rtrs_srv_sess *sess)
sysfs_remove_group(&sess->kobj, &rtrs_srv_sess_attr_group); sysfs_remove_group(&sess->kobj, &rtrs_srv_sess_attr_group);
put_kobj: put_kobj:
kobject_del(&sess->kobj); kobject_del(&sess->kobj);
kobject_put(&sess->kobj);
destroy_root: destroy_root:
kobject_put(&sess->kobj);
rtrs_srv_destroy_once_sysfs_root_folders(sess); rtrs_srv_destroy_once_sysfs_root_folders(sess);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment