From: Casey Schaufler <casey@schaufler-ca.com>
To: Al Viro <viro@zeniv.linux.org.uk>,
Dan Carpenter <dan.carpenter@oracle.com>
Cc: James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] smack: Fix a memory leak in smack_add_opt()
Date: Fri, 21 Dec 2018 09:41:28 -0800 [thread overview]
Message-ID: <bd05d276-91a2-c849-065c-18aa17a0ff82@schaufler-ca.com> (raw)
In-Reply-To: <20181221164219.GZ2217@ZenIV.linux.org.uk>
On 12/21/2018 8:42 AM, Al Viro wrote:
> On Fri, Dec 21, 2018 at 04:36:54PM +0000, Al Viro wrote:
>> On Fri, Dec 21, 2018 at 12:09:58PM +0300, Dan Carpenter wrote:
>>> The function is leaking "opts" on the error paths.
>>>
>>> Fixes: 90e3b564ab93 ("smack: take the guts of smack_parse_opts_str() into a new helper")
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> D'oh... Applied, thanks for spotting that braino.
> On the other hand, it's easier to do it this way - the caller will free the damn thing
> on error, anyway:
What tree/branch is the happening in?
>
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 11da1e2531c8..cf0c0380e5dd 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -608,6 +608,7 @@ static int smack_add_opt(int token, const char *s, void **mnt_opts)
> opts = kzalloc(sizeof(struct smack_mnt_opts), GFP_KERNEL);
> if (!opts)
> return -ENOMEM;
> + *mnt_opts = opts;
> }
> if (!s)
> return -ENOMEM;
> @@ -639,7 +640,6 @@ static int smack_add_opt(int token, const char *s, void **mnt_opts)
> opts->fstransmute = s;
> break;
> }
> - *mnt_opts = opts;
> return 0;
>
> out_opt_err:
>
prev parent reply other threads:[~2018-12-21 17:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 9:09 Dan Carpenter
2018-12-21 16:36 ` Al Viro
2018-12-21 16:42 ` Al Viro
2018-12-21 17:41 ` Casey Schaufler [this message]
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=bd05d276-91a2-c849-065c-18aa17a0ff82@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=dan.carpenter@oracle.com \
--cc=jmorris@namei.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®