diff mbox series

[2/4] scsi: pm80xx: Do not check the address-of value for NULL

Message ID 20211101232825.2350233-3-ipylypiv@google.com (mailing list archive)
State Accepted
Headers show
Series small pm80xx cleanups and fixes | expand

Commit Message

Igor Pylypiv Nov. 1, 2021, 11:28 p.m. UTC
Address-of operator cannot return NULL.

Reviewed-by: Vishakha Channapattan <vishakhavc@google.com>
Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
---
 drivers/scsi/pm8001/pm8001_hwi.c | 24 ++++--------------------
 drivers/scsi/pm8001/pm80xx_hwi.c | 29 ++++++++---------------------
 2 files changed, 12 insertions(+), 41 deletions(-)

Comments

Jinpu Wang Nov. 2, 2021, 7:06 a.m. UTC | #1
On Tue, Nov 2, 2021 at 12:28 AM Igor Pylypiv <ipylypiv@google.com> wrote:
>
> Address-of operator cannot return NULL.
>
> Reviewed-by: Vishakha Channapattan <vishakhavc@google.com>
> Signed-off-by: Igor Pylypiv <ipylypiv@google.com>
Acked-by: Jack Wang <jinpu.wang@ionos.com>
Thanks
> ---
>  drivers/scsi/pm8001/pm8001_hwi.c | 24 ++++--------------------
>  drivers/scsi/pm8001/pm80xx_hwi.c | 29 ++++++++---------------------
>  2 files changed, 12 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
> index 63690508313b..1a593f2b2c87 100644
> --- a/drivers/scsi/pm8001/pm8001_hwi.c
> +++ b/drivers/scsi/pm8001/pm8001_hwi.c
> @@ -2304,21 +2304,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
>
>         psataPayload = (struct sata_completion_resp *)(piomb + 4);
>         status = le32_to_cpu(psataPayload->status);
> +       param = le32_to_cpu(psataPayload->param);
>         tag = le32_to_cpu(psataPayload->tag);
>
>         if (!tag) {
>                 pm8001_dbg(pm8001_ha, FAIL, "tag null\n");
>                 return;
>         }
> +
>         ccb = &pm8001_ha->ccb_info[tag];
> -       param = le32_to_cpu(psataPayload->param);
> -       if (ccb) {
> -               t = ccb->task;
> -               pm8001_dev = ccb->device;
> -       } else {
> -               pm8001_dbg(pm8001_ha, FAIL, "ccb null\n");
> -               return;
> -       }
> +       t = ccb->task;
> +       pm8001_dev = ccb->device;
>
>         if (t) {
>                 if (t->dev && (t->dev->lldd_dev))
> @@ -2335,10 +2331,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
>         }
>
>         ts = &t->task_status;
> -       if (!ts) {
> -               pm8001_dbg(pm8001_ha, FAIL, "ts null\n");
> -               return;
> -       }
>
>         if (status)
>                 pm8001_dbg(pm8001_ha, IOERR,
> @@ -2695,14 +2687,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
>         u32 dev_id = le32_to_cpu(psataPayload->device_id);
>         unsigned long flags;
>
> -       ccb = &pm8001_ha->ccb_info[tag];
> -
> -       if (ccb) {
> -               t = ccb->task;
> -               pm8001_dev = ccb->device;
> -       } else {
> -               pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n");
> -       }
>         if (event)
>                 pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event);
>
> diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
> index 4f887925c9d2..f9e997b23d42 100644
> --- a/drivers/scsi/pm8001/pm80xx_hwi.c
> +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
> @@ -2399,21 +2399,17 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
>
>         psataPayload = (struct sata_completion_resp *)(piomb + 4);
>         status = le32_to_cpu(psataPayload->status);
> +       param = le32_to_cpu(psataPayload->param);
>         tag = le32_to_cpu(psataPayload->tag);
>
>         if (!tag) {
>                 pm8001_dbg(pm8001_ha, FAIL, "tag null\n");
>                 return;
>         }
> +
>         ccb = &pm8001_ha->ccb_info[tag];
> -       param = le32_to_cpu(psataPayload->param);
> -       if (ccb) {
> -               t = ccb->task;
> -               pm8001_dev = ccb->device;
> -       } else {
> -               pm8001_dbg(pm8001_ha, FAIL, "ccb null\n");
> -               return;
> -       }
> +       t = ccb->task;
> +       pm8001_dev = ccb->device;
>
>         if (t) {
>                 if (t->dev && (t->dev->lldd_dev))
> @@ -2430,10 +2426,6 @@ mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
>         }
>
>         ts = &t->task_status;
> -       if (!ts) {
> -               pm8001_dbg(pm8001_ha, FAIL, "ts null\n");
> -               return;
> -       }
>
>         if (status != IO_SUCCESS) {
>                 pm8001_dbg(pm8001_ha, FAIL,
> @@ -2804,15 +2796,6 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
>         u32 dev_id = le32_to_cpu(psataPayload->device_id);
>         unsigned long flags;
>
> -       ccb = &pm8001_ha->ccb_info[tag];
> -
> -       if (ccb) {
> -               t = ccb->task;
> -               pm8001_dev = ccb->device;
> -       } else {
> -               pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n");
> -               return;
> -       }
>         if (event)
>                 pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event);
>
> @@ -2826,6 +2809,10 @@ static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
>                 return;
>         }
>
> +       ccb = &pm8001_ha->ccb_info[tag];
> +       t = ccb->task;
> +       pm8001_dev = ccb->device;
> +
>         if (unlikely(!t || !t->lldd_task || !t->dev)) {
>                 pm8001_dbg(pm8001_ha, FAIL, "task or dev null\n");
>                 return;
> --
> 2.33.1.1089.g2158813163f-goog
>
diff mbox series

Patch

diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
index 63690508313b..1a593f2b2c87 100644
--- a/drivers/scsi/pm8001/pm8001_hwi.c
+++ b/drivers/scsi/pm8001/pm8001_hwi.c
@@ -2304,21 +2304,17 @@  mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 
 	psataPayload = (struct sata_completion_resp *)(piomb + 4);
 	status = le32_to_cpu(psataPayload->status);
+	param = le32_to_cpu(psataPayload->param);
 	tag = le32_to_cpu(psataPayload->tag);
 
 	if (!tag) {
 		pm8001_dbg(pm8001_ha, FAIL, "tag null\n");
 		return;
 	}
+
 	ccb = &pm8001_ha->ccb_info[tag];
-	param = le32_to_cpu(psataPayload->param);
-	if (ccb) {
-		t = ccb->task;
-		pm8001_dev = ccb->device;
-	} else {
-		pm8001_dbg(pm8001_ha, FAIL, "ccb null\n");
-		return;
-	}
+	t = ccb->task;
+	pm8001_dev = ccb->device;
 
 	if (t) {
 		if (t->dev && (t->dev->lldd_dev))
@@ -2335,10 +2331,6 @@  mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	}
 
 	ts = &t->task_status;
-	if (!ts) {
-		pm8001_dbg(pm8001_ha, FAIL, "ts null\n");
-		return;
-	}
 
 	if (status)
 		pm8001_dbg(pm8001_ha, IOERR,
@@ -2695,14 +2687,6 @@  static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	u32 dev_id = le32_to_cpu(psataPayload->device_id);
 	unsigned long flags;
 
-	ccb = &pm8001_ha->ccb_info[tag];
-
-	if (ccb) {
-		t = ccb->task;
-		pm8001_dev = ccb->device;
-	} else {
-		pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n");
-	}
 	if (event)
 		pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event);
 
diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
index 4f887925c9d2..f9e997b23d42 100644
--- a/drivers/scsi/pm8001/pm80xx_hwi.c
+++ b/drivers/scsi/pm8001/pm80xx_hwi.c
@@ -2399,21 +2399,17 @@  mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 
 	psataPayload = (struct sata_completion_resp *)(piomb + 4);
 	status = le32_to_cpu(psataPayload->status);
+	param = le32_to_cpu(psataPayload->param);
 	tag = le32_to_cpu(psataPayload->tag);
 
 	if (!tag) {
 		pm8001_dbg(pm8001_ha, FAIL, "tag null\n");
 		return;
 	}
+
 	ccb = &pm8001_ha->ccb_info[tag];
-	param = le32_to_cpu(psataPayload->param);
-	if (ccb) {
-		t = ccb->task;
-		pm8001_dev = ccb->device;
-	} else {
-		pm8001_dbg(pm8001_ha, FAIL, "ccb null\n");
-		return;
-	}
+	t = ccb->task;
+	pm8001_dev = ccb->device;
 
 	if (t) {
 		if (t->dev && (t->dev->lldd_dev))
@@ -2430,10 +2426,6 @@  mpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	}
 
 	ts = &t->task_status;
-	if (!ts) {
-		pm8001_dbg(pm8001_ha, FAIL, "ts null\n");
-		return;
-	}
 
 	if (status != IO_SUCCESS) {
 		pm8001_dbg(pm8001_ha, FAIL,
@@ -2804,15 +2796,6 @@  static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 	u32 dev_id = le32_to_cpu(psataPayload->device_id);
 	unsigned long flags;
 
-	ccb = &pm8001_ha->ccb_info[tag];
-
-	if (ccb) {
-		t = ccb->task;
-		pm8001_dev = ccb->device;
-	} else {
-		pm8001_dbg(pm8001_ha, FAIL, "No CCB !!!. returning\n");
-		return;
-	}
 	if (event)
 		pm8001_dbg(pm8001_ha, FAIL, "SATA EVENT 0x%x\n", event);
 
@@ -2826,6 +2809,10 @@  static void mpi_sata_event(struct pm8001_hba_info *pm8001_ha, void *piomb)
 		return;
 	}
 
+	ccb = &pm8001_ha->ccb_info[tag];
+	t = ccb->task;
+	pm8001_dev = ccb->device;
+
 	if (unlikely(!t || !t->lldd_task || !t->dev)) {
 		pm8001_dbg(pm8001_ha, FAIL, "task or dev null\n");
 		return;