[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1593368939.4487.13.camel@linux.ibm.com>
Date: Sun, 28 Jun 2020 11:28:59 -0700
From: James Bottomley <jejb@...ux.ibm.com>
To: trix@...hat.com, martin.petersen@...cle.com
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] scsi: scsi_transport_spi: fix function pointer check.
On Sat, 2020-06-27 at 06:32 -0700, trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
>
> clang static analysis flags several null function pointer problems.
>
> drivers/scsi/scsi_transport_spi.c:374:1: warning: Called function
> pointer is null (null dereference) [core.CallAndMessage]
> spi_transport_max_attr(offset, "%d\n");
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Reviewing the store_spi_store_max macro
>
> if (i->f->set_##field)
> return -EINVAL;
>
> should be
>
> if (!i->f->set_##field)
> return -EINVAL;
>
> Signed-off-by: Tom Rix <trix@...hat.com>
Fixes: 9b161a4d3e83 "[SCSI] scsi_transport_spi: convert to attribute groups")
Gosh that's an old bug ... clearly no-one is manually setting width or
offset.
Reviewed-by: James Bottomley <jejb@...ux.ibm.com>
James
> ---
> drivers/scsi/scsi_transport_spi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/scsi_transport_spi.c
> b/drivers/scsi/scsi_transport_spi.c
> index f8661062ef95..f3d5b1bbd5aa 100644
> --- a/drivers/scsi/scsi_transport_spi.c
> +++ b/drivers/scsi/scsi_transport_spi.c
> @@ -339,7 +339,7 @@ store_spi_transport_##field(struct device *dev,
> \
> struct spi_transport_attrs *tp
> \
> = (struct spi_transport_attrs *)&starget-
> >starget_data; \
>
> \
> - if (i->f->set_##field)
> \
> + if (!i->f->set_##field)
> \
> return -EINVAL;
> \
> val = simple_strtoul(buf, NULL, 0);
> \
> if (val > tp->max_##field)
> \
Powered by blists - more mailing lists