[PATCH] aic7xxx_core: Avoid shift overflow in aic7xxx init

From: Jesse Taube

Date: Tue Nov 24 2026 - 10:17:23 EST


When built with _FORTIFY_SOURCE there was a shift overflow in ahc_init.
Target mode was conditionally disabled based on `ahc->unit` which was
initialized to -1 and later is set to the real unit number.
The Linux kernel does not support target mode so undconditionally
disable target mode.

Signed-off-by: Jesse Taube <jtaubepe@xxxxxxxxxx>
---
drivers/scsi/aic7xxx/aic7xxx_core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index b9761f9f0bbc..eeae5965f79f 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -5276,10 +5276,9 @@ ahc_init(struct ahc_softc *ahc)
ahc->flags |= AHC_INITIATORROLE;

/*
- * Only allow target mode features if this unit has them enabled.
+ * Only disallow target mode features.
*/
- if ((AHC_TMODE_ENABLE & (0x1 << ahc->unit)) == 0)
- ahc->features &= ~AHC_TARGETMODE;
+ ahc->features &= ~AHC_TARGETMODE;

ahc->init_level++;

--
2.56.0