Skip to contentSkip to conversation

sym53c8xx: Avoid undefined behaviour in drivers/scsi/sym53c8xx_2/sym_hipd.c:762

PATCH Applied Helge Deller 3 participants 3 messages Aug 10, 2017 – Aug 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sym53c8xx: Avoid undefined behaviour in drivers/scsi/sym53c8xx_2/sym_hipd.c:762

On parisc I see this UBSAN warning with a sym53c896:

 UBSAN: Undefined behaviour in ./drivers/scsi/sym53c8xx_2/sym_hipd.c:762:24
 index -1903078336 is out of range for type 'u32 [7]'

Avoid this warning by switching to dev64_ul().

drivers/scsi/sym53c8xx_2/sym_hipd.c +1 -1
index 6b349e3..15ff285a9 100644
@@ -759,7 +759,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
 	/*
 	 * Maximum synchronous period factor supported by the chip.
 	 */
-	period = (11 * div_10M[np->clock_divn - 1]) / (4 * np->clock_khz);
+	period = div64_ul(11 * div_10M[np->clock_divn - 1], 4 * np->clock_khz);
 	np->maxsync = period > 2540 ? 254 : period / 10;
 
 	/*
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Helge Deller

On parisc I see this UBSAN warning with a sym53c896:

 UBSAN: Undefined behaviour in ./drivers/scsi/sym53c8xx_2/sym_hipd.c:762:24
 index -1903078336 is out of range for type 'u32 [7]'

Avoid this warning by switching to dev64_ul().

                            div64_ul() ^

Otherwise,

Signature · 6 lines
Johannes Thumshirn                                          Storage
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
#2 lore raw
In reply to Helge Deller

Helge,

Quoted 6 lines

On parisc I see this UBSAN warning with a sym53c896:

 UBSAN: Undefined behaviour in ./drivers/scsi/sym53c8xx_2/sym_hipd.c:762:24
 index -1903078336 is out of range for type 'u32 [7]'

Avoid this warning by switching to dev64_ul().

Applied to 4.14/scsi-queue. Thank you, Helge!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering