Skip to content

Commit dc80df5

Browse files
RoelKluintorvalds
authored andcommitted
mwave: fix read buffer overflow
Check whether index is within bounds before grabbing the element. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent dd5d81f commit dc80df5

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎drivers/char/mwave/mwavedd.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -281,12 +281,6 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
281281
case IOCTL_MW_REGISTER_IPC: {
282282
unsigned int ipcnum = (unsigned int) ioarg;
283283

284-
PRINTK_3(TRACE_MWAVE,
285-
"mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
286-
" ipcnum %x entry usIntCount %x\n",
287-
ipcnum,
288-
pDrvData->IPCs[ipcnum].usIntCount);
289-
290284
if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) {
291285
PRINTK_ERROR(KERN_ERR_MWAVE
292286
"mwavedd::mwave_ioctl:"
@@ -295,6 +289,12 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
295289
ipcnum);
296290
return -EINVAL;
297291
}
292+
PRINTK_3(TRACE_MWAVE,
293+
"mwavedd::mwave_ioctl IOCTL_MW_REGISTER_IPC"
294+
" ipcnum %x entry usIntCount %x\n",
295+
ipcnum,
296+
pDrvData->IPCs[ipcnum].usIntCount);
297+
298298
lock_kernel();
299299
pDrvData->IPCs[ipcnum].bIsHere = FALSE;
300300
pDrvData->IPCs[ipcnum].bIsEnabled = TRUE;
@@ -310,18 +310,18 @@ static long mwave_ioctl(struct file *file, unsigned int iocmd,
310310
case IOCTL_MW_GET_IPC: {
311311
unsigned int ipcnum = (unsigned int) ioarg;
312312

313-
PRINTK_3(TRACE_MWAVE,
314-
"mwavedd::mwave_ioctl IOCTL_MW_GET_IPC"
315-
" ipcnum %x, usIntCount %x\n",
316-
ipcnum,
317-
pDrvData->IPCs[ipcnum].usIntCount);
318313
if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) {
319314
PRINTK_ERROR(KERN_ERR_MWAVE
320315
"mwavedd::mwave_ioctl:"
321316
" IOCTL_MW_GET_IPC: Error:"
322317
" Invalid ipcnum %x\n", ipcnum);
323318
return -EINVAL;
324319
}
320+
PRINTK_3(TRACE_MWAVE,
321+
"mwavedd::mwave_ioctl IOCTL_MW_GET_IPC"
322+
" ipcnum %x, usIntCount %x\n",
323+
ipcnum,
324+
pDrvData->IPCs[ipcnum].usIntCount);
325325

326326
lock_kernel();
327327
if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) {

0 commit comments

Comments
 (0)