LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Steve French <smfrench@gmail.com>, Colin King <colin.king@canonical.com>
Cc: Ronnie Sahlberg <lsahlber@redhat.com>,
	Steve French <sfrench@samba.org>,
	CIFS <linux-cifs@vger.kernel.org>,
	samba-technical <samba-technical@lists.samba.org>,
	LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] cifs: dir: fix memory leak in cifs_mknod
Date: Fri, 20 Apr 2018 12:48:05 -0500	[thread overview]
Message-ID: <67525f3c-f6f2-d1b2-c6eb-66b2315e6530@embeddedor.com> (raw)
In-Reply-To: <CAH2r5mtYQujfeEUpEiE557o3YccD9QwWCTLCJFbBoF7zbYcggQ@mail.gmail.com>

Hi Steve,

On 04/20/2018 12:37 PM, Steve French wrote:
> I noticed a similar problem with the tcon link leak on that (which
> Colin and Gustavo pointed out - thank you!) but also in another return
> statement, so updated the original patch of Ronnie's merging the fixes
> 
> https://git.samba.org/sfrench/cifs-2.6.git/?p=sfrench/cifs-2.6.git;a=commit;h=167bc5de08dc97695f9d5c7069c3e69f409ff80b
> 
> 
> Let me know if you see any problems with it.
> 

Looks correct to me.

Thanks
--
Gustavo

> On Fri, Apr 20, 2018 at 8:19 AM, Gustavo A. R. Silva
> <gustavo@embeddedor.com> wrote:
>> Free allocated memory for full_path and xid before return.
>>
>> Addresses-Coverity-ID: 1468029 ("Resource leak")
>> Fixes: 49162bfde140 ("cifs: do not allow creating sockets except with
>> SMB1 posix exensions")
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>>   fs/cifs/dir.c | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
>> index f0a759d..71e32d9 100644
>> --- a/fs/cifs/dir.c
>> +++ b/fs/cifs/dir.c
>> @@ -684,8 +684,11 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
>>                  goto mknod_out;
>>          }
>>
>> -       if (!S_ISCHR(mode) && !S_ISBLK(mode))
>> +       if (!S_ISCHR(mode) && !S_ISBLK(mode)) {
>> +               kfree(full_path);
>> +               free_xid(xid);
>>                  return -EPERM;
>> +       }
>>
>>          if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
>>                  goto mknod_out;
>> --
>> 2.7.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 

  reply	other threads:[~2018-04-20 17:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-20 13:19 Gustavo A. R. Silva
2018-04-20 17:37 ` Steve French
2018-04-20 17:48   ` Gustavo A. R. Silva [this message]
2018-04-20 18:02   ` Pavel Shilovsky

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=67525f3c-f6f2-d1b2-c6eb-66b2315e6530@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=colin.king@canonical.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lsahlber@redhat.com \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    --subject='Re: [PATCH] cifs: dir: fix memory leak in cifs_mknod' \
    /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

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).