linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: Joe Perches <joe@perches.com>, Pan Bian <bianpan201604@163.com>,
	Artem Bityutskiy <dedekind1@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, Pan Bian <bianpan2016@163.com>
Subject: Re: [PATCH 1/1] mtd: ubi: fix improper return value
Date: Sun, 4 Dec 2016 22:36:55 +0100	[thread overview]
Message-ID: <85f33a89-f349-eac0-a072-d99867b796fb@gmail.com> (raw)
In-Reply-To: <1480883619.4534.6.camel@perches.com>

On 12/04/2016 09:33 PM, Joe Perches wrote:
> On Sun, 2016-12-04 at 13:48 +0100, Marek Vasut wrote:
>> On 12/04/2016 07:12 AM, Pan Bian wrote:
>>> From: Pan Bian <bianpan2016@163.com>
>>>
>>> When __vmalloc() returns a NULL pointer, the region is not checked, and
>>> we cannot make sure that only 0xFF bytes are present at offset. Thus,
>>> returning 0 seems improper.
>>>
>>> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189081
>>>
>>> Signed-off-by: Pan Bian <bianpan2016@163.com>
>>> ---
>>>  drivers/mtd/ubi/io.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
> []
>>> @@ -1413,7 +1413,7 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
>>>  	buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
>>>  	if (!buf) {
>>>  		ubi_err(ubi, "cannot allocate memory to check for 0xFFs");
>>> -		return 0;
>>> +		return -ENOMEM;
>>
>> I wonder if you shouldn't also nuke the ubi_err() , because when you run
>> out of memory, printk() will likely also fail.
> 
> No, not really.  printk doesn't allocate memory.
> 
> But the ubi_err should be removed because all memory
> allocations that fail without a specific GFP_NOWARN
> flag already have a dump_stack() call.

Ah, thanks for the correction :-)

-- 
Best regards,
Marek Vasut

      parent reply	other threads:[~2016-12-04 21:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-04  6:12 [PATCH 1/1] mtd: ubi: fix improper return value Pan Bian
2016-12-04 12:48 ` Marek Vasut
2016-12-04 20:33   ` Joe Perches
2016-12-04 20:52     ` Richard Weinberger
2016-12-05  7:09       ` Artem Bityutskiy
2016-12-05  8:23         ` Boris Brezillon
2016-12-05  9:49           ` Artem Bityutskiy
2016-12-04 21:36     ` Marek Vasut [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=85f33a89-f349-eac0-a072-d99867b796fb@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=bianpan201604@163.com \
    --cc=bianpan2016@163.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /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;
as well as URLs for NNTP newsgroup(s).