public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Sapozhnikov <alsp705@gmail.com>
To: Hannes Reinecke <hare@suse.com>
Cc: Alexandr Sapozhnikov <alsp705@gmail.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: [PATCH] [PATCH] NULL check in ahc_handle_scsiint()
Date: Thu, 16 Feb 2023 14:20:34 +0300	[thread overview]
Message-ID: <20230216112034.104-1-alsp705@gmail.com> (raw)

From: Alexandr Sapozhnikov <alsp705@gmail.com>

After having been compared to NULL value at aic7xxx_core.c:1569, 
pointer 'scb' is passed as 2nd parameter in call to function 
'ahc_qinfifo_requeue_tail' at aic7xxx_core.c:1864, :1876, :1890, 
where it is dereferenced.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
 drivers/scsi/aic7xxx/aic7xxx_core.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index a396f04..6840729 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -1819,13 +1819,15 @@ ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat)
 			tag = SCB_LIST_NULL;
 			if (ahc_sent_msg(ahc, AHCMSG_1B, ABORT_TASK, TRUE)
 			 || ahc_sent_msg(ahc, AHCMSG_1B, ABORT_TASK_SET, TRUE)) {
-				if (ahc->msgout_buf[ahc->msgout_index - 1]
-				 == ABORT_TASK)
-					tag = scb->hscb->tag;
-				ahc_print_path(ahc, scb);
-				printk("SCB %d - Abort%s Completed.\n",
+				if (scb) {
+					if (ahc->msgout_buf[ahc->msgout_index - 1]
+					== ABORT_TASK)
+						tag = scb->hscb->tag;
+					ahc_print_path(ahc, scb);
+					printk("SCB %d - Abort%s Completed.\n",
 				       scb->hscb->tag, tag == SCB_LIST_NULL ?
 				       "" : " Tag");
+				}
 				ahc_abort_scbs(ahc, target, channel,
 					       saved_lun, tag,
 					       ROLE_INITIATOR,
@@ -1861,7 +1863,8 @@ ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat)
 				tinfo->curr.transport_version = 2;
 				tinfo->goal.transport_version = 2;
 				tinfo->goal.ppr_options = 0;
-				ahc_qinfifo_requeue_tail(ahc, scb);
+				if (scb)
+					ahc_qinfifo_requeue_tail(ahc, scb);
 				printerror = 0;
 			} else if (ahc_sent_msg(ahc, AHCMSG_EXT,
 						EXTENDED_WDTR, FALSE)) {
@@ -1873,7 +1876,8 @@ ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat)
 					      MSG_EXT_WDTR_BUS_8_BIT,
 					      AHC_TRANS_CUR|AHC_TRANS_GOAL,
 					      /*paused*/TRUE);
-				ahc_qinfifo_requeue_tail(ahc, scb);
+				if (scb)
+					ahc_qinfifo_requeue_tail(ahc, scb);
 				printerror = 0;
 			} else if (ahc_sent_msg(ahc, AHCMSG_EXT,
 						EXTENDED_SDTR, FALSE)) {
@@ -1887,7 +1891,8 @@ ahc_handle_scsiint(struct ahc_softc *ahc, u_int intstat)
 						/*ppr_options*/0,
 						AHC_TRANS_CUR|AHC_TRANS_GOAL,
 						/*paused*/TRUE);
-				ahc_qinfifo_requeue_tail(ahc, scb);
+				if (scb)
+					ahc_qinfifo_requeue_tail(ahc, scb);
 				printerror = 0;
 			}
 		}
-- 
2.5.3


                 reply	other threads:[~2023-02-16 11:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230216112034.104-1-alsp705@gmail.com \
    --to=alsp705@gmail.com \
    --cc=hare@suse.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox