From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "André Moreira" <andrem.33333@gmail.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: core: devio: validate device and interface before buffer allocation
Date: Fri, 10 Jul 2026 15:14:46 +0200 [thread overview]
Message-ID: <2026071038-magma-joystick-dfef@gregkh> (raw)
In-Reply-To: <20260624023532.63009-1-andrem.33333@gmail.com>
On Tue, Jun 23, 2026 at 11:35:31PM -0300, André Moreira wrote:
> 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.
Nice find and cleanup, thanks!
greg k-h
next prev parent reply other threads:[~2026-07-10 13:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 2:35 [PATCH] usb: core: devio: validate device and interface before buffer allocation André Moreira
2026-07-10 13:14 ` Greg Kroah-Hartman [this message]
2026-07-10 20:29 ` Andre Moreira
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026071038-magma-joystick-dfef@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=andrem.33333@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.