Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1735111

Re: [PATCH] mtd: spi-nor: Kill check with no effect

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>
Newsgroups linux.kernel
Subject Re: [PATCH] mtd: spi-nor: Kill check with no effect
Date Tue, 19 Sep 2017 19:20:02 +0200
Message-ID <urulI-8fP-5@gated-at.bofh.it> (permalink)
References <uqIAp-AU-3@gated-at.bofh.it> <ur0QI-4nB-65@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Language en-US
Content-Transfer-Encoding 8bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 70
Organization linux.* mail to news gateway
X-Original-Cc linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com, dwmw2@infradead.org
X-Original-Date Tue, 19 Sep 2017 19:10:35 +0200
X-Original-Message-ID <45983c6e-6fff-0712-b84d-5ae18c830872@wedev4u.fr>
X-Original-References <20170917141352.23691-1-richard@nod.at> <20170918114451.74e6fe68@bbrezillon>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1735111

Show key headers only | View raw


Hi Richard,

Le 18/09/2017 à 11:44, Boris Brezillon a écrit :
> On Sun, 17 Sep 2017 16:13:52 +0200
> Richard Weinberger <richard@nod.at> wrote:
> 
>> header.major is of type u8 and cannot be negative.
> 
> I guess you meant header.minor here.
> 
>>
>> Detected by CoverityScan CID#1417858 ("Integer handling issues")
>>
>> Fixes: f384b352cbf0 ("mtd: spi-nor: parse Serial Flash Discoverable
>> Parameters (SFDP) tables")
>> Signed-off-by: Richard Weinberger <richard@nod.at>
>> ---
>> Cyrille,
>>
>> I'm not sure what exactly you wanted to test.
>> Maybe it makes sense casting header.major to s8 before checking against < 0?
>>

Actually I hesitated between checking the exact match with one of the 3
major.minor pairs defined for each version of the JESD216 specification:

JESD216: 1.0
JESD216 rev A: 1.5
JESD216 rev B (the latest one): 1.6

I was wondering whether I should accept 1.1, 1.2, 1.3 and 1.4
(unofficial) pairs too and also later versions, which should be backward
compatible with JESD216 rev B, like rev B is backward compatible with
rev A and so on...

Finally I've chosen to accept everything after 1.0 to give a chance to
next revisions to be supported as much as possible by the current code.
The major number should not change but actually the test upon the minor
value is useless as every unsigned number is greater than or equal to 0 ;)

So once Boris comment taken into account:

Acked-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>

Best regards,

Cyrille

>> Thanks,
>> //richard
>> ---
>>  drivers/mtd/spi-nor/spi-nor.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
>> index d71765739a93..4b86decdf13e 100644
>> --- a/drivers/mtd/spi-nor/spi-nor.c
>> +++ b/drivers/mtd/spi-nor/spi-nor.c
>> @@ -2252,8 +2252,7 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
>>  
>>  	/* Check the SFDP header version. */
>>  	if (le32_to_cpu(header.signature) != SFDP_SIGNATURE ||
>> -	    header.major != SFDP_JESD216_MAJOR ||
>> -	    header.minor < SFDP_JESD216_MINOR)
>> +	    header.major != SFDP_JESD216_MAJOR)
>>  		return -EINVAL;
>>  
>>  	/*
> 
> 

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH] mtd: spi-nor: Kill check with no effect Richard Weinberger <richard@nod.at> - 2017-09-17 16:20 +0200
  Re: [PATCH] mtd: spi-nor: Kill check with no effect Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-09-18 11:50 +0200
    Re: [PATCH] mtd: spi-nor: Kill check with no effect Richard Weinberger <richard@nod.at> - 2017-09-18 15:40 +0200
    Re: [PATCH] mtd: spi-nor: Kill check with no effect Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> - 2017-09-19 19:20 +0200

csiph-web