Skip to content

Commit bb509a6

Browse files
ian-abbottgregkh
authored andcommitted
comedi: Fix memory leak in compat_insnlist()
`compat_insnlist()` handles the 32-bit version of the `COMEDI_INSNLIST` ioctl (whenwhen `CONFIG_COMPAT` is enabled). It allocates memory to temporarily hold an array of `struct comedi_insn` converted from the 32-bit version in user space. This memory is only being freed if there is a fault while filling the array, otherwise it is leaked. Add a call to `kfree()` to fix the leak. Fixes: b8d47d8 ("comedi: get rid of compat_alloc_user_space() mess in COMEDI_INSNLIST compat") Cc: Al Viro <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: [email protected] Cc: <[email protected]> # 5.13+ Signed-off-by: Ian Abbott <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7af526c commit bb509a6

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/comedi/comedi_fops.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,6 +3090,7 @@ static int compat_insnlist(struct file *file, unsigned long arg)
30903090
mutex_lock(&dev->mutex);
30913091
rc = do_insnlist_ioctl(dev, insns, insnlist32.n_insns, file);
30923092
mutex_unlock(&dev->mutex);
3093+
kfree(insns);
30933094
return rc;
30943095
}
30953096

0 commit comments

Comments
 (0)