linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion
@ 2019-06-14  8:36 Young Xiao
  2019-06-14  9:47 ` Saurav Kashyap
  2019-06-20 20:50 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Young Xiao @ 2019-06-14  8:36 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, jejb, martin.petersen, linux-scsi, linux-kernel
  Cc: Young Xiao

sc_cmd->sense_buffer is not guaranteed to be allocated so we need to
sc_cmd->check if the pointer is NULL before trying to copy anything into it.

See commit 16a611154dc1 ("scsi: qedf: Check if sense buffer has been allocated
during completion") for details.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 8def63c..44a5e59 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1789,9 +1789,11 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd *io_req,
 			fcp_sns_len = SCSI_SENSE_BUFFERSIZE;
 		}
 
-		memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
-		if (fcp_sns_len)
-			memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
+		if (sc_cmd->sense_buffer) {
+			memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
+			if (fcp_sns_len)
+				memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
+		}
 
 		/* return RQ entries */
 		for (i = 0; i < num_rq; i++)
-- 
2.7.4


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

* Re: [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion
  2019-06-14  8:36 [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion Young Xiao
@ 2019-06-14  9:47 ` Saurav Kashyap
  2019-06-20 20:50 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Saurav Kashyap @ 2019-06-14  9:47 UTC (permalink / raw)
  To: Young Xiao, QLogic-Storage-Upstream, jejb, martin.petersen,
	linux-scsi, linux-kernel



-----Original Message-----
From: <linux-scsi-owner@vger.kernel.org> on behalf of Young Xiao
<92siuyang@gmail.com>
Date: Friday, 14 June 2019 at 2:06 PM
To: "QLogic-Storage-Upstream@qlogic.com"
<QLogic-Storage-Upstream@qlogic.com>, "jejb@linux.ibm.com"
<jejb@linux.ibm.com>, "martin.petersen@oracle.com"
<martin.petersen@oracle.com>, "linux-scsi@vger.kernel.org"
<linux-scsi@vger.kernel.org>, "linux-kernel@vger.kernel.org"
<linux-kernel@vger.kernel.org>
Cc: Young Xiao <92siuyang@gmail.com>
Subject: [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated
during completion

>sc_cmd->sense_buffer is not guaranteed to be allocated so we need to
>sc_cmd->check if the pointer is NULL before trying to copy anything into
>it.
>
>See commit 16a611154dc1 ("scsi: qedf: Check if sense buffer has been
>allocated
>during completion") for details.
>
>Signed-off-by: Young Xiao <92siuyang@gmail.com>
>---
> drivers/scsi/bnx2fc/bnx2fc_io.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c
>b/drivers/scsi/bnx2fc/bnx2fc_io.c
>index 8def63c..44a5e59 100644
>--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
>+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
>@@ -1789,9 +1789,11 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd
>*io_req,
> 			fcp_sns_len = SCSI_SENSE_BUFFERSIZE;
> 		}
> 
>-		memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
>-		if (fcp_sns_len)
>-			memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
>+		if (sc_cmd->sense_buffer) {
>+			memset(sc_cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
>+			if (fcp_sns_len)
>+				memcpy(sc_cmd->sense_buffer, rq_data, fcp_sns_len);
>+		}
> 
> 		/* return RQ entries */
> 		for (i = 0; i < num_rq; i++)
>-- 
>2.7.4

Thanks for the patch
Acked-by: Saurav Kashyap <skashyap@marvell.com>

Thanks,
~Saurav
>


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

* Re: [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion
  2019-06-14  8:36 [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion Young Xiao
  2019-06-14  9:47 ` Saurav Kashyap
@ 2019-06-20 20:50 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2019-06-20 20:50 UTC (permalink / raw)
  To: Young Xiao
  Cc: QLogic-Storage-Upstream, jejb, martin.petersen, linux-scsi, linux-kernel


Hi Young,

> sc_cmd->sense_buffer is not guaranteed to be allocated so we need to
> sc_cmd->check if the pointer is NULL before trying to copy anything
> into it.

bnx2fc does not appear to use a driver-specific sense buffer.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2019-06-20 20:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14  8:36 [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion Young Xiao
2019-06-14  9:47 ` Saurav Kashyap
2019-06-20 20:50 ` 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).