Skip to contentSkip to conversation

scsi: fnic: Validate io_req before others

PATCH Applied Karan Tilak Kumar 3 participants 4 messages Nov 21, 2020 – Dec 1, 2020

Subsystems (2)
lore
Share & tools
lore

Karan Tilak Kumar

author maintainer
#0 lore raw

PATCH 1/1 scsi: fnic: Validate io_req before others

We need to check for a valid io_req before
we check other data. Also, removing
redundant checks.

---
 drivers/scsi/fnic/fnic.h      | 2 +-
 drivers/scsi/fnic/fnic_scsi.c | 9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)
drivers/scsi/fnic/fnic.h +1 -1
index e4d399f41a0a..69f373b53132 100644
@@ -39,7 +39,7 @@
 
 #define DRV_NAME		"fnic"
 #define DRV_DESCRIPTION		"Cisco FCoE HBA Driver"
-#define DRV_VERSION		"1.6.0.52"
+#define DRV_VERSION		"1.6.0.53"
 #define PFX			DRV_NAME ": "
 #define DFX                     DRV_NAME "%d: "
 
drivers/scsi/fnic/fnic_scsi.c +4 -5
index 532c3c7ae372..36744968378f 100644
@@ -1735,15 +1735,14 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
 			continue;
 		}
 
-		cmd_rport = starget_to_rport(scsi_target(sc->device));
-		if (rport != cmd_rport) {
+		io_req = (struct fnic_io_req *)CMD_SP(sc);
+		if (!io_req) {
 			spin_unlock_irqrestore(io_lock, flags);
 			continue;
 		}
 
-		io_req = (struct fnic_io_req *)CMD_SP(sc);
-
-		if (!io_req || rport != cmd_rport) {
+		cmd_rport = starget_to_rport(scsi_target(sc->device));
+		if (rport != cmd_rport) {
 			spin_unlock_irqrestore(io_lock, flags);
 			continue;
 		}
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw

Looks good.

On 11/20/20, 6:33 PM, "Karan Tilak Kumar" <[email protected]> wrote:

    We need to check for a valid io_req before
    we check other data. Also, removing
    redundant checks.

    Signed-off-by: Karan Tilak Kumar <[email protected]>
    Signed-off-by: Satish Kharat <[email protected]>
    ---
     drivers/scsi/fnic/fnic.h      | 2 +-
     drivers/scsi/fnic/fnic_scsi.c | 9 ++++-----
     2 files changed, 5 insertions(+), 6 deletions(-)

    diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
    index e4d399f41a0a..69f373b53132 100644
    --- a/drivers/scsi/fnic/fnic.h
    +++ b/drivers/scsi/fnic/fnic.h
    @@ -39,7 +39,7 @@

     #define DRV_NAME		"fnic"
     #define DRV_DESCRIPTION		"Cisco FCoE HBA Driver"
    -#define DRV_VERSION		"1.6.0.52"
    +#define DRV_VERSION		"1.6.0.53"
     #define PFX			DRV_NAME ": "
     #define DFX                     DRV_NAME "%d: "

    diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
    index 532c3c7ae372..36744968378f 100644
    --- a/drivers/scsi/fnic/fnic_scsi.c
    +++ b/drivers/scsi/fnic/fnic_scsi.c
    @@ -1735,15 +1735,14 @@ void fnic_terminate_rport_io(struct fc_rport *rport)
     			continue;
     		}

    -		cmd_rport = starget_to_rport(scsi_target(sc->device));
    -		if (rport != cmd_rport) {
    +		io_req = (struct fnic_io_req *)CMD_SP(sc);
    +		if (!io_req) {
     			spin_unlock_irqrestore(io_lock, flags);
     			continue;
     		}

    -		io_req = (struct fnic_io_req *)CMD_SP(sc);
    -
    -		if (!io_req || rport != cmd_rport) {
    +		cmd_rport = starget_to_rport(scsi_target(sc->device));
    +		if (rport != cmd_rport) {
     			spin_unlock_irqrestore(io_lock, flags);
     			continue;
     		}
    -- 
    2.29.2
#2 lore raw
In reply to Karan Tilak Kumar

Karan,

Quoted 2 lines

We need to check for a valid io_req before we check other data. Also, removing redundant checks.

Applied to 5.11/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering