linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_snapshot_group.
@ 2020-05-27 19:55 wu000273
  2020-05-27 22:00 ` Ryusuke Konishi
  0 siblings, 1 reply; 2+ messages in thread
From: wu000273 @ 2020-05-27 19:55 UTC (permalink / raw)
  To: kjlu
  Cc: wu000273, Ryusuke Konishi, Andrew Morton, Vyacheslav Dubeyko,
	linux-nilfs, linux-kernel

From: Qiushi Wu <wu000273@umn.edu>

kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object. Previous
commit "b8eb718348b8" fixed a similar problem.

Fixes: a5a7332a291b ("nilfs2: add /sys/fs/nilfs2/<device>/mounted_snapshots/<snapshot>group")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
---
 fs/nilfs2/sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index e60be7bb55b0..b2517c5e773a 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -209,8 +209,10 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)
 					    "%llu", root->cno);
 	}
 
-	if (err)
+	if (err) {
+		kobject_put(&root->snapshot_kobj);
 		return err;
+	}
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_snapshot_group.
  2020-05-27 19:55 [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_snapshot_group wu000273
@ 2020-05-27 22:00 ` Ryusuke Konishi
  0 siblings, 0 replies; 2+ messages in thread
From: Ryusuke Konishi @ 2020-05-27 22:00 UTC (permalink / raw)
  To: Andrew Morton; +Cc: kjlu, wu000273, Vyacheslav Dubeyko, linux-nilfs, LKML

Andrew,

Apply this, please.

Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>

On Thu, May 28, 2020 at 4:55 AM <wu000273@umn.edu> wrote:
>
> From: Qiushi Wu <wu000273@umn.edu>
>
> kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to
> properly clean up the memory associated with the object. Previous
> commit "b8eb718348b8" fixed a similar problem.
>
> Fixes: a5a7332a291b ("nilfs2: add /sys/fs/nilfs2/<device>/mounted_snapshots/<snapshot>group")
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
>  fs/nilfs2/sysfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
> index e60be7bb55b0..b2517c5e773a 100644
> --- a/fs/nilfs2/sysfs.c
> +++ b/fs/nilfs2/sysfs.c
> @@ -209,8 +209,10 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)
>                                             "%llu", root->cno);
>         }
>
> -       if (err)
> +       if (err) {
> +               kobject_put(&root->snapshot_kobj);
>                 return err;
> +       }
>
>         return 0;
>  }
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-27 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 19:55 [PATCH] nilfs2: Fix reference count leak in nilfs_sysfs_create_snapshot_group wu000273
2020-05-27 22:00 ` Ryusuke Konishi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).