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: v4.9.215~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=60bea48fd40116fd60f5950f45bb35b450d70714;p=platform%2Fkernel%2Flinux-amlogic.git cmd64x: potential buffer overflow in cmd64x_program_timings() [ Upstream commit 117fcc3053606d8db5cef8821dca15022ae578bb ] 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 Signed-off-by: Sasha Levin --- diff --git a/drivers/ide/cmd64x.c b/drivers/ide/cmd64x.c index b127ed60c733..9dde8390da09 100644 --- a/drivers/ide/cmd64x.c +++ b/drivers/ide/cmd64x.c @@ -65,6 +65,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); /*