linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Cc: linux-usb@vger.kernel.org, andreyknvl@gmail.com,
	stern@rowland.harvard.edu, b-liu@ti.com, johan@kernel.org,
	oneukum@suse.com, linux-kernel@vger.kernel.org,
	usb-storage@lists.one-eyed-alien.net
Subject: Re: [PATCH] drivers/usb: refactor min(), max() with min_t(), max_t()
Date: Tue, 12 Nov 2024 16:14:17 +0100	[thread overview]
Message-ID: <2024111251-spill-hatchback-72da@gregkh> (raw)
In-Reply-To: <20241112150437.3508388-1-snovitoll@gmail.com>

On Tue, Nov 12, 2024 at 08:04:37PM +0500, Sabyrzhan Tasbolatov wrote:
> Scanned the current drivers/usb code with `max\(.*\(` and `min\(.*\(`
> regexp queries to find casting inside of min() and max() which
> may lead to subtle bugs or even security vulnerabilities,
> especially if negative values are involved.
> 
> Let's refactor to min_t() and max_t() specifying the data type
> to ensure it's applicable for the both compareable arguments.
> It should address potential type promotion issues and improves type safety.
> 
> Signed-off-by: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
> ---
>  drivers/usb/core/config.c                    |  2 +-
>  drivers/usb/gadget/composite.c               | 12 ++++++------
>  drivers/usb/gadget/configfs.c                |  2 +-
>  drivers/usb/gadget/function/f_fs.c           |  6 +++---
>  drivers/usb/gadget/function/f_mass_storage.c |  8 ++++----
>  drivers/usb/gadget/function/uvc_video.c      |  4 ++--
>  drivers/usb/gadget/legacy/raw_gadget.c       |  4 ++--
>  drivers/usb/gadget/udc/omap_udc.c            |  4 ++--
>  drivers/usb/gadget/usbstring.c               |  2 +-
>  drivers/usb/host/ehci-hcd.c                  |  2 +-
>  drivers/usb/host/oxu210hp-hcd.c              |  4 ++--
>  drivers/usb/host/r8a66597-hcd.c              |  2 +-
>  drivers/usb/misc/usbtest.c                   |  3 ++-
>  drivers/usb/mon/mon_bin.c                    |  2 +-
>  drivers/usb/musb/musb_core.c                 |  2 +-
>  drivers/usb/musb/musb_gadget_ep0.c           |  2 +-
>  drivers/usb/musb/musb_host.c                 |  5 ++---
>  drivers/usb/serial/io_edgeport.c             |  2 +-
>  drivers/usb/serial/sierra.c                  |  2 +-
>  drivers/usb/storage/sddr09.c                 |  4 ++--
>  drivers/usb/storage/sddr55.c                 |  8 ++++----
>  21 files changed, 41 insertions(+), 41 deletions(-)

Can you break these up to at least "one per drivers/usb/*" subdirectory
to make it easier to review and apply?

thanks,

greg k-h

  reply	other threads:[~2024-11-12 15:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-12 15:04 [PATCH] drivers/usb: refactor min(), max() with min_t(), max_t() Sabyrzhan Tasbolatov
2024-11-12 15:14 ` Greg KH [this message]
2024-11-12 15:58   ` [PATCH v2 0/8] drivers/usb: refactor min/max with min_t/max_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 1/8] drivers/usb/gadget: refactor min with min_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 2/8] drivers/usb/core: refactor max with max_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 3/8] drivers/usb/host: refactor min/max with min_t/max_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 4/8] drivers/usb/misc: refactor min with min_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 5/8] drivers/usb/mon: " Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 6/8] drivers/usb/musb: refactor min/max with min_t/max_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 7/8] drivers/usb/serial: refactor min with min_t Sabyrzhan Tasbolatov
2024-11-12 15:58     ` [PATCH v2 8/8] drivers/usb/storage: " Sabyrzhan Tasbolatov
2024-11-17 19:55     ` [PATCH v2 0/8] drivers/usb: refactor min/max with min_t/max_t Andy Shevchenko

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=2024111251-spill-hatchback-72da@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=b-liu@ti.com \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    --cc=snovitoll@gmail.com \
    --cc=stern@rowland.harvard.edu \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).