[mtd:nand/next 12/20] drivers/mtd/nand/raw/nand_base.c:1466 nand_prog_page_op() warn: impossible condition '(status < 0) => (0-255 < 0)'

Miquel Raynal miquel.raynal at bootlin.com
Wed Mar 3 08:34:27 GMT 2021


Hi Sascha,

Sascha Hauer <s.hauer at pengutronix.de> wrote on Wed, 3 Mar 2021 07:40:13
+0100:

> On Wed, Mar 03, 2021 at 08:54:42AM +0300, Dan Carpenter wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next
> > head:   095b4dabff2a929cefd330110c5c578956213188
> > commit: 19877b2c5de809e6f553e158c263b7a8bb65222d [12/20] mtd: nand: fix error handling in nand_prog_page_op() #2
> > config: x86_64-randconfig-m001-20210302 (attached as .config)
> > compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
> > 
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp at intel.com>
> > Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
> > 
> > New smatch warnings:
> > drivers/mtd/nand/raw/nand_base.c:1466 nand_prog_page_op() warn: impossible condition '(status < 0) => (0-255 < 0)'
> > 
> > Old smatch warnings:
> > drivers/mtd/nand/raw/nand_base.c:842 nand_setup_interface() warn: missing error code 'ret'
> > 
> > vim +1466 drivers/mtd/nand/raw/nand_base.c
> > 
> > 97d90da8a88694 drivers/mtd/nand/nand_base.c     Boris Brezillon 2017-11-30  1437  int nand_prog_page_op(struct nand_chip *chip, unsigned int page,
> > 97d90da8a88694 drivers/mtd/nand/nand_base.c     Boris Brezillon 2017-11-30  1438  		      unsigned int offset_in_page, const void *buf,
> > 97d90da8a88694 drivers/mtd/nand/nand_base.c     Boris Brezillon 2017-11-30  1439  		      unsigned int len)
> > 97d90da8a88694 drivers/mtd/nand/nand_base.c     Boris Brezillon 2017-11-30  1440  {
> > 97d90da8a88694 drivers/mtd/nand/nand_base.c     Boris Brezillon 2017-11-30  1441  	struct mtd_info *mtd = nand_to_mtd(chip);
> > 19877b2c5de809 drivers/mtd/nand/raw/nand_base.c Sascha Hauer    2021-02-05  1442  	u8 status;
> >                                                                                         ^^^^^^^^^^
> > This needs to be changed to an int  
> 
> &status is passed to nand_status_op(), so this gives us:
> 
> drivers/mtd/nand/raw/nand_base.c:1457:30: error: passing argument 2 of ‘nand_status_op’ from incompatible pointer type [-Werror=incompatible-pointer-types]
> 
> I'd rather suggest the following.
> 
> Sascha
> 
> --------------------------------8<---------------------------------
> 
> From ea216bee86618a04ea743fbdb59835c28e92c7c9 Mon Sep 17 00:00:00 2001
> From: Sascha Hauer <s.hauer at pengutronix.de>
> Date: Wed, 3 Mar 2021 07:32:35 +0100
> Subject: [PATCH] fixup! mtd: nand: fix error handling in nand_prog_page_op()
>  #2
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 0f6babefaed2..4f263c22c80d 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -1462,9 +1462,10 @@ int nand_prog_page_op(struct nand_chip *chip, unsigned int page,
>  				     page);
>  		chip->legacy.write_buf(chip, buf, len);
>  		chip->legacy.cmdfunc(chip, NAND_CMD_PAGEPROG, -1, -1);
> -		status = chip->legacy.waitfunc(chip);
> -		if (status < 0)
> -			return status;
> +		ret = chip->legacy.waitfunc(chip);
> +		if (ret < 0)
> +			return ret;
> +		status = ret;

Yep, LGTM. I edited the commit and pushed -f nand/next. Don't tell
Richard ;-)

Cheers,
Miquèl



More information about the linux-mtd mailing list