From: Stepan Ionichev <sozdayvek@gmail.com>
To: hare@suse.com
Cc: James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org,
Stepan Ionichev <sozdayvek@gmail.com>
Subject: [PATCH] scsi: aic7xxx: avoid NULL deref of cur_column in ahc_print_register()
Date: Sat, 9 May 2026 14:56:56 +0500 [thread overview]
Message-ID: <20260509095656.7143-1-sozdayvek@gmail.com> (raw)
ahc_print_register() takes an optional 'cur_column' pointer that may
be NULL. The function already guards two of its three accesses:
if (cur_column != NULL && *cur_column >= wrap_point) {
printk("\n");
*cur_column = 0;
}
...
if (cur_column != NULL)
*cur_column += printed;
return (printed);
The early-return path taken when 'table' is NULL forgot the guard:
if (table == NULL) {
printed += printk(" ");
*cur_column += printed; /* unconditional deref */
return (printed);
}
If a caller passes (cur_column == NULL, table == NULL) the kernel
NULL-derefs in the early-return path while otherwise doing the right
thing in the rest of the function.
smatch flags the inconsistency:
drivers/scsi/aic7xxx/aic7xxx_core.c:7067 ahc_print_register() error:
we previously assumed 'cur_column' could be null (see line 7060)
Mirror the existing NULL check used at the function's tail before
updating *cur_column on the early-return path.
No functional change for callers that pass a non-NULL cur_column.
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
drivers/scsi/aic7xxx/aic7xxx_core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index b9761f9f0..82eb84afb 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -7064,7 +7064,8 @@ ahc_print_register(const ahc_reg_parse_entry_t *table, u_int num_entries,
printed = printk("%s[0x%x]", name, value);
if (table == NULL) {
printed += printk(" ");
- *cur_column += printed;
+ if (cur_column != NULL)
+ *cur_column += printed;
return (printed);
}
printed_mask = 0;
--
2.43.0
reply other threads:[~2026-05-09 17:13 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=20260509095656.7143-1-sozdayvek@gmail.com \
--to=sozdayvek@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=hare@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.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