Skip to contentSkip to conversation

scsi: bnx2fc: Check if sense buffer has been allocated during completion

PATCH In review Young Xiao 3 participants 3 messages Jun 14, 2019 – Jun 20, 2019

Subsystems (2)
lore
Share & tools
lore

Young Xiao

author
#0 lore raw

PATCH 1/1 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.

---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_io.c +5 -3
index 8def63c..44a5e59 100644
@@ -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++)
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw

-----Original Message-----
From: <[email protected]> on behalf of Young Xiao <[email protected]>
Date: Friday, 14 June 2019 at 2:06 PM
To: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Cc: Young Xiao <[email protected]>
Subject: [PATCH] scsi: bnx2fc: Check if sense buffer has been allocated during completion

Quoted 33 lines

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.

---
drivers/scsi/bnx2fc/bnx2fc_io.c | 8 +++++---

1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/bnx2fc/bnx2fc_io.c +5 -3
index 8def63c..44a5e59 100644
@@ -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 */
Quoted 3 lines
		for (i = 0; i < num_rq; i++)
Signature · 1 line
2.7.4

Thanks for the patch

Thanks,
~Saurav

Quoted 1 line
#2 lore raw
In reply to Young Xiao

Hi Young,

Quoted 3 lines

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.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering