mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
synced 2026-11-10 20:48:12 +00:00
usb: core: devio: validate device and interface before buffer allocation
The proc_ioctl() function currently allocates a buffer using kmalloc() before checking the USB device state and resolving the interface number. If either validation fails, the function must free the buffer and return an error. Move these checks to the top of the function to fail early. This avoids unnecessary memory allocation and deallocation on error paths, removes the nested 'else' structure, and eliminates redundant kfree() calls, making the code cleaner and easier to maintain. Signed-off-by: André Moreira <andrem.33333@gmail.com> Link: https://patch.msgid.link/20260624023532.63009-1-andrem.33333@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
612551bf7c
commit
83f0355cf4
1 changed files with 8 additions and 5 deletions
Loading…
Add table
Add a link
Reference in a new issue