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


Groups > linux.kernel > #1733958

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

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mtd: spi-nor: Kill check with no effect
Date 2017-09-18 11:50 +0200
Message-ID <ur0QI-4nB-65@gated-at.bofh.it> (permalink)
References <uqIAp-AU-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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?
> 
> 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 | Next 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