sym53c8xx: Avoid undefined behaviour in drivers/scsi/sym53c8xx_2/sym_hipd.c:762
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().
Signed-off-by Helge Deller <[email protected]>
drivers/scsi/sym53c8xx_2/sym_hipd.c +1 -1
@@ -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 ;/*
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,
Reviewed-by Johannes Thumshirn <[email protected]>
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
Martin K. Petersen
AppliedHelge,
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