mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Peng Fan <fanpeng@loongson.cn>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Xuefeng Li <lixuefeng@loongson.cn>,
	Tiezhu Yang <yangtiezhu@loongson.cn>
Subject: Re: [PATCH] fs/read_write.c: Fix memory leak in read_write.c
Date: Wed, 24 Jun 2020 04:24:47 +0100	[thread overview]
Message-ID: <20200624032447.GK21350@casper.infradead.org> (raw)
In-Reply-To: <1592968023-20383-1-git-send-email-fanpeng@loongson.cn>

On Wed, Jun 24, 2020 at 11:07:03AM +0800, Peng Fan wrote:
> kmemleak report:
> unreferenced object 0x98000002bb591d00 (size 256):
>   comm "ftest03", pid 24778, jiffies 4301603810 (age 490.665s)
>   hex dump (first 32 bytes):
>     00 01 04 20 01 00 00 00 80 00 00 00 00 00 00 00  ... ............
>     f0 02 04 20 01 00 00 00 80 00 00 00 00 00 00 00  ... ............
>   backtrace:
>     [<0000000050b162cb>] __kmalloc+0x234/0x438
>     [<00000000491da9c7>] rw_copy_check_uvector+0x1ac/0x1f0
>     [<00000000b0dddb43>] import_iovec+0x50/0xe8
>     [<00000000ae843d73>] vfs_readv+0x50/0xb0
>     [<00000000c7216b06>] do_readv+0x80/0x160
>     [<00000000cad79c3f>] syscall_common+0x34/0x58
> 
> This is because "iov" allocated by kmalloc() is not destroyed. Under normal
> circumstances, "ret_pointer" should be equal to "iov". But if the previous 
> statements fails to execute, and the allocation is successful, then the
> block of memory will not be released, because it is necessary to 
> determine whether they are equal. So we need to change the order.

This patch doesn't make sense.  It will _introduce_ a memory leak,
not fix one.

      reply	other threads:[~2020-06-24  3:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24  3:07 Peng Fan
2020-06-24  3:24 ` Matthew Wilcox [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=20200624032447.GK21350@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=fanpeng@loongson.cn \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yangtiezhu@loongson.cn \
    /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®