Linux NILFS development
 help / color / mirror / Atom feed
From: Dongliang Mu <mudongliangabcd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ryusuke Konishi
	<konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: paskripkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	Dongliang Mu
	<mudongliangabcd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH] nilfs2: fix memory leak in nilfs_sysfs_create_device_group
Date: Mon,  6 Sep 2021 12:13:30 +0800	[thread overview]
Message-ID: <20210906041330.2065214-1-mudongliangabcd@gmail.com> (raw)

The commit 8fd0c1b0647a ("nilfs2: fix memory leak in
nilfs_sysfs_delete_device_group") adds a kobject_put to free the leaking
object name. However, it is incomplete to only add kobject_put in the
nilfs_sysfs_delete_device_group. The function
nilfs_sysfs_create_device_group also needs the kobject_put to
free the object name in the error handling part.

Fix this by adding kobject_put in the error handling code of
nilfs_sysfs_create_device_group.

Signed-off-by: Dongliang Mu <mudongliangabcd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 fs/nilfs2/sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c
index 68e8d61e28dd..7ab60711ca76 100644
--- a/fs/nilfs2/sysfs.c
+++ b/fs/nilfs2/sysfs.c
@@ -1024,6 +1024,7 @@ int nilfs_sysfs_create_device_group(struct super_block *sb)
 
 cleanup_dev_kobject:
 	kobject_del(&nilfs->ns_dev_kobj);
+	kobject_put(&nilfs->ns_dev_kobj);
 
 free_dev_subgroups:
 	kfree(nilfs->ns_dev_subgroups);
-- 
2.25.1


             reply	other threads:[~2021-09-06  4:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06  4:13 Dongliang Mu [this message]
     [not found] ` <20210906041330.2065214-1-mudongliangabcd-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-09-06  5:43   ` [PATCH] nilfs2: fix memory leak in nilfs_sysfs_create_device_group Dongliang Mu
     [not found]     ` <CAD-N9QUHfoqOOxDuKniMi8VGLR2j6g50BBy45eAL0kPRrntmgA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-09-06 15:56       ` Pavel Skripkin
     [not found]         ` <aa2fb8c6-ef6b-a1ca-d598-b0814529a31d-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-09-06 16:47           ` Pavel Skripkin
     [not found]             ` <53fb4217-21b8-ac46-bb39-581a4c9837a4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2021-09-06 16:51               ` Pavel Skripkin
2021-09-07  4:00               ` Dongliang Mu
     [not found]                 ` <CAD-N9QUjd-yNVa2uOac434tgyd2wXEQ6Z=aA9Yu9-_UANv7YjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2021-09-13  5:23                   ` Dongliang Mu
2021-09-07  3:37           ` Dongliang Mu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210906041330.2065214-1-mudongliangabcd@gmail.com \
    --to=mudongliangabcd-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=paskripkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox