From: Dan Carpenter Date: Tue, 7 Jan 2020 13:04:41 +0000 (+0300) Subject: cmd64x: potential buffer overflow in cmd64x_program_timings() X-Git-Tag: v5.15~4604^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=117fcc3053606d8db5cef8821dca15022ae578bb;p=platform%2Fkernel%2Flinux-starfive.git cmd64x: potential buffer overflow in cmd64x_program_timings() The "drive->dn" value is a u8 and it is controlled by root only, but it could be out of bounds here so let's check. Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller --- diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index a1898e1..943bf94 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c @@ -66,6 +66,9 @@ static void cmd64x_program_timings(ide_drive_t *drive, u8 mode) struct ide_timing t; u8 arttim = 0; + if (drive->dn >= ARRAY_SIZE(drwtim_regs)) + return; + ide_timing_compute(drive, mode, &t, T, 0); /*