[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181221164219.GZ2217@ZenIV.linux.org.uk>
Date: Fri, 21 Dec 2018 16:42:19 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: Casey Schaufler <casey@...aufler-ca.com>,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] smack: Fix a memory leak in smack_add_opt()
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@...cle.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:
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:
Powered by blists - more mailing lists