* [PATCH] scsi: scsi_transport_spi: fix function pointer check.
@ 2020-06-27 13:32 trix
2020-06-28 18:28 ` James Bottomley
2020-06-30 3:22 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: trix @ 2020-06-27 13:32 UTC (permalink / raw)
To: jejb, martin.petersen; +Cc: linux-scsi, linux-kernel, Tom Rix
From: Tom Rix <trix@redhat.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@redhat.com>
---
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) \
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: scsi_transport_spi: fix function pointer check.
2020-06-27 13:32 [PATCH] scsi: scsi_transport_spi: fix function pointer check trix
@ 2020-06-28 18:28 ` James Bottomley
2020-06-30 3:22 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: James Bottomley @ 2020-06-28 18:28 UTC (permalink / raw)
To: trix, martin.petersen; +Cc: linux-scsi, linux-kernel
On Sat, 2020-06-27 at 06:32 -0700, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.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@redhat.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@linux.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)
> \
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: scsi_transport_spi: fix function pointer check.
2020-06-27 13:32 [PATCH] scsi: scsi_transport_spi: fix function pointer check trix
2020-06-28 18:28 ` James Bottomley
@ 2020-06-30 3:22 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-06-30 3:22 UTC (permalink / raw)
To: jejb, trix; +Cc: Martin K . Petersen, linux-scsi, linux-kernel
On Sat, 27 Jun 2020 06:32:42 -0700, trix@redhat.com wrote:
> 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
>
> [...]
Applied to 5.8/scsi-fixes, thanks!
[1/1] scsi: scsi_transport_spi: Fix function pointer check
https://git.kernel.org/mkp/scsi/c/5aee52c44d91
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-30 3:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-27 13:32 [PATCH] scsi: scsi_transport_spi: fix function pointer check trix
2020-06-28 18:28 ` James Bottomley
2020-06-30 3:22 ` Martin K. Petersen
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).