All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: fas216: fix sense buffer initialization
@ 2018-01-18 13:16 ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2018-01-18 13:16 UTC (permalink / raw)
  To: Russell King, James E.J. Bottomley, Martin K. Petersen
  Cc: Arnd Bergmann, linux-arm-kernel, linux-scsi, linux-kernel

While testing with the ARM specific memset() macro removed, I ran
into a compiler warning that shows an old bug:

drivers/scsi/arm/fas216.c: In function 'fas216_rq_sns_done':
drivers/scsi/arm/fas216.c:2014:40: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]

It turns out that the definition of the scsi_cmd structure changed back
in linux-2.6.25, so now we clear only four bytes (sizeof(pointer)) instead
of 96 (SCSI_SENSE_BUFFERSIZE). I did not check whether we actually need
to initialize the buffer here, but it's clear that if we do it, we
should use the correct size.

Fixes: de25deb18016 ("[SCSI] use dynamically allocated sense buffer")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/arm/fas216.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index f4775ca70bab..27bda2b05de6 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2011,7 +2011,7 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
 		 * have valid data in the sense buffer that could
 		 * confuse the higher levels.
 		 */
-		memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
+		memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 //printk("scsi%d.%c: sense buffer: ", info->host->host_no, '0' + SCpnt->device->id);
 //{ int i; for (i = 0; i < 32; i++) printk("%02x ", SCpnt->sense_buffer[i]); printk("\n"); }
 	/*
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] scsi: fas216: fix sense buffer initialization
@ 2018-01-18 13:16 ` Arnd Bergmann
  0 siblings, 0 replies; 4+ messages in thread
From: Arnd Bergmann @ 2018-01-18 13:16 UTC (permalink / raw)
  To: linux-arm-kernel

While testing with the ARM specific memset() macro removed, I ran
into a compiler warning that shows an old bug:

drivers/scsi/arm/fas216.c: In function 'fas216_rq_sns_done':
drivers/scsi/arm/fas216.c:2014:40: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]

It turns out that the definition of the scsi_cmd structure changed back
in linux-2.6.25, so now we clear only four bytes (sizeof(pointer)) instead
of 96 (SCSI_SENSE_BUFFERSIZE). I did not check whether we actually need
to initialize the buffer here, but it's clear that if we do it, we
should use the correct size.

Fixes: de25deb18016 ("[SCSI] use dynamically allocated sense buffer")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/arm/fas216.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index f4775ca70bab..27bda2b05de6 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2011,7 +2011,7 @@ static void fas216_rq_sns_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
 		 * have valid data in the sense buffer that could
 		 * confuse the higher levels.
 		 */
-		memset(SCpnt->sense_buffer, 0, sizeof(SCpnt->sense_buffer));
+		memset(SCpnt->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
 //printk("scsi%d.%c: sense buffer: ", info->host->host_no, '0' + SCpnt->device->id);
 //{ int i; for (i = 0; i < 32; i++) printk("%02x ", SCpnt->sense_buffer[i]); printk("\n"); }
 	/*
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: fas216: fix sense buffer initialization
  2018-01-18 13:16 ` Arnd Bergmann
@ 2018-01-19  2:43   ` Martin K. Petersen
  -1 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2018-01-19  2:43 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Russell King, James E.J. Bottomley, Martin K. Petersen,
	linux-arm-kernel, linux-scsi, linux-kernel


Arnd,

> While testing with the ARM specific memset() macro removed, I ran
> into a compiler warning that shows an old bug:
>
> drivers/scsi/arm/fas216.c: In function 'fas216_rq_sns_done':
> drivers/scsi/arm/fas216.c:2014:40: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
>
> It turns out that the definition of the scsi_cmd structure changed back
> in linux-2.6.25, so now we clear only four bytes (sizeof(pointer)) instead
> of 96 (SCSI_SENSE_BUFFERSIZE). I did not check whether we actually need
> to initialize the buffer here, but it's clear that if we do it, we
> should use the correct size.

Applied to 4.16/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] scsi: fas216: fix sense buffer initialization
@ 2018-01-19  2:43   ` Martin K. Petersen
  0 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2018-01-19  2:43 UTC (permalink / raw)
  To: linux-arm-kernel


Arnd,

> While testing with the ARM specific memset() macro removed, I ran
> into a compiler warning that shows an old bug:
>
> drivers/scsi/arm/fas216.c: In function 'fas216_rq_sns_done':
> drivers/scsi/arm/fas216.c:2014:40: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Werror=sizeof-pointer-memaccess]
>
> It turns out that the definition of the scsi_cmd structure changed back
> in linux-2.6.25, so now we clear only four bytes (sizeof(pointer)) instead
> of 96 (SCSI_SENSE_BUFFERSIZE). I did not check whether we actually need
> to initialize the buffer here, but it's clear that if we do it, we
> should use the correct size.

Applied to 4.16/scsi-queue. Thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-19  2:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-18 13:16 [PATCH] scsi: fas216: fix sense buffer initialization Arnd Bergmann
2018-01-18 13:16 ` Arnd Bergmann
2018-01-19  2:43 ` Martin K. Petersen
2018-01-19  2:43   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.