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.5.6~97 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=fec984eeb40ec27a6a0792f136483336c2d3a0ff;p=users%2Fdwmw2%2Flinux.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 a1898e11b04e6..943bf944bf722 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); /*