All of lore.kernel.org
 help / color / mirror / Atom feed
From: Navid Emamdoost <navid.emamdoost@gmail.com>
To: dsterba@suse.cz
Cc: emamd001@umn.edu, smccaman@umn.edu, kjlu@umn.edu,
	Navid Emamdoost <navid.emamdoost@gmail.com>,
	David Sterba <dsterba@suse.com>, Jeff Layton <jlayton@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	Deepa Dinamani <deepa.kernel@gmail.com>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v3] fs: affs: fix a memory leak in affs_remount
Date: Wed,  2 Oct 2019 16:52:37 -0500	[thread overview]
Message-ID: <20191002215242.14317-1-navid.emamdoost@gmail.com> (raw)
In-Reply-To: <20191002092221.GJ2751@suse.cz>

In affs_remount if data is provided it is duplicated into new_opts.
The allocated memory for new_opts is only released if pare_options fail.
But the variable is not used anywhere. So the new_opts should be
removed.

Fixes: c8f33d0bec99 ("affs: kstrdup() memory handling")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
Changes in v2:
	-- fix typo
Changes in v3:
	-- remove the call to kstrdup, as new_opts is not used anymore.
---
 fs/affs/super.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/fs/affs/super.c b/fs/affs/super.c
index cc463ae47c12..b6c6080d186c 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -565,10 +565,6 @@ affs_remount(struct super_block *sb, int *flags, char *data)
 	char			 volume[32];
 	char			*prefix = NULL;
 
-	new_opts = kstrdup(data, GFP_KERNEL);
-	if (data && !new_opts)
-		return -ENOMEM;
-
 	pr_debug("%s(flags=0x%x,opts=\"%s\")\n", __func__, *flags, data);
 
 	sync_filesystem(sb);
@@ -579,7 +575,6 @@ affs_remount(struct super_block *sb, int *flags, char *data)
 			   &blocksize, &prefix, volume,
 			   &mount_flags)) {
 		kfree(prefix);
-		kfree(new_opts);
 		return -EINVAL;
 	}
 
-- 
2.17.1


  parent reply	other threads:[~2019-10-02 21:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30  3:21 [PATCH] fs: affs: fix a memroy leak in affs_remount Navid Emamdoost
2019-09-30  6:02 ` [PATCH] fs: affs: fix a memory " Markus Elfring
2019-09-30  6:02   ` Markus Elfring
2019-09-30 21:01   ` [PATCH v2] " Navid Emamdoost
2019-10-01  8:30     ` Markus Elfring
2019-10-01  8:30       ` Markus Elfring
2019-10-01 17:34       ` Navid Emamdoost
2019-10-01 17:34         ` Navid Emamdoost
2019-10-02  5:09         ` [v2] " Markus Elfring
2019-10-02  5:09           ` Markus Elfring
2019-10-02  5:09         ` Markus Elfring
2019-10-02  5:09           ` Markus Elfring
2019-10-02  9:22     ` [PATCH v2] " David Sterba
2019-10-02 16:59       ` Navid Emamdoost
2019-10-02 21:52       ` Navid Emamdoost [this message]
2019-10-30 11:44         ` [PATCH v3] " David Sterba
2019-09-30 21:01   ` [PATCH] " Navid Emamdoost
2019-09-30 21:01     ` Navid Emamdoost

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=20191002215242.14317-1-navid.emamdoost@gmail.com \
    --to=navid.emamdoost@gmail.com \
    --cc=deepa.kernel@gmail.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=emamd001@umn.edu \
    --cc=gustavo@embeddedor.com \
    --cc=jlayton@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kjlu@umn.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=smccaman@umn.edu \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.