lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFEp6-387oUTN=Xj+xOWYrfVu9CUvD8Tsu9_nnnpigYamMwE8g@mail.gmail.com>
Date: Thu, 22 Jan 2026 13:01:31 +0100
From: Loic Poulain <loic.poulain@....qualcomm.com>
To: Slark Xiao <slark_xiao@....com>
Cc: Jakub Kicinski <kuba@...nel.org>, Sergey Ryazanov <ryazanov.s.a@...il.com>,
        quic_qianyu@...cinc.com, davem@...emloft.net,
        johannes@...solutions.net, netdev@...r.kernel.org,
        zaihan@...ealasia.net, johan@...nel.org, andrew+netdev@...n.ch,
        edumazet@...gle.com, linux-kernel@...r.kernel.org, dnlplm@...il.com,
        manivannan.sadhasivam@...aro.org, pabeni@...hat.com, mani@...nel.org
Subject: Re: Re:Re: [net-next,v7,3/8] net: wwan: core: split port creation and registration

On Thu, Jan 22, 2026 at 3:32 AM Slark Xiao <slark_xiao@....com> wrote:
>
>
>
> At 2026-01-16 11:24:54, "Slark Xiao" <slark_xiao@....com> wrote:
> >
> >
> >At 2026-01-16 10:44:35, "Jakub Kicinski" <kuba@...nel.org> wrote:
> >>This is an AI-generated review of your patch. The human sending this
> >>email has considered the AI review valid, or at least plausible.
> >>
> >>For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> >>---
> >>net: wwan: core: split port creation and registration
> >>
> >>This patch splits the port creation function to prepare for upcoming GNSS
> >>port type support. It separates device_register() into device_initialize()
> >>and device_add(), and moves minor number allocation into the new
> >>wwan_port_register_wwan() function.
> >>
> >>> diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
> >>> index 1da935e84008..1a9a77d597e6 100644
> >>> --- a/drivers/net/wwan/wwan_core.c
> >>> +++ b/drivers/net/wwan/wwan_core.c
> >>> @@ -357,7 +357,8 @@ static void wwan_port_destroy(struct device *dev)
> >>>  {
> >>>     struct wwan_port *port = to_wwan_port(dev);
> >>>
> >>> -   ida_free(&minors, MINOR(port->dev.devt));
> >>> +   if (dev->class == &wwan_class)
> >>> +           ida_free(&minors, MINOR(dev->devt));
> >>>     mutex_destroy(&port->data_lock);
> >>>     mutex_destroy(&port->ops_lock);
> >>>     kfree(port);
> >>
> >>[ ... ]
> >>
> >>> +/* Register a regular WWAN port device (e.g. AT, MBIM, etc.) */
> >>> +static int wwan_port_register_wwan(struct wwan_port *port)
> >>> +{
> >>> +   struct wwan_device *wwandev = to_wwan_dev(port->dev.parent);
> >>> +   char namefmt[0x20];
> >>> +   int minor, err;
> >>> +
> >>> +   /* A port is exposed as character device, get a minor */
> >>> +   minor = ida_alloc_range(&minors, 0, WWAN_MAX_MINORS - 1, GFP_KERNEL);
> >>> +   if (minor < 0)
> >>> +           return minor;
> >>> +
> >>> +   port->dev.class = &wwan_class;
> >>> +   port->dev.devt = MKDEV(wwan_major, minor);
> >>
> >>[ ... ]
> >>
> >>> +   err = device_add(&port->dev);
> >>> +
> >>> +   mutex_unlock(&wwan_register_lock);
> >>> +
> >>> +   if (err) {
> >>> +           ida_free(&minors, minor);
> >>                ^^^^^^^^^^^^^^^^^^^^^^^^
>
> >>
> Hi Sergey,
> Can we modify it like this?
>
> +       if (err) {
> +               ida_free(&minors, minor);
> +               port->dev.class = NULL;
>
> This shall be able to avoid the double free issue.

I would prefer to let wwan_port_destroy() handle this, meaning we
shouldn’t free the IDA here and should simply return the error code,
but your approach is also acceptable.

Regards,
Loic

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ