mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Xu Yang <xu.yang_2@nxp.com>
Cc: "Russell King (Oracle)" <linux@armlinux.org.uk>,
	hkallweit1@gmail.com, o.rempel@pengutronix.de, pabeni@redhat.com,
	netdev@vger.kernel.org, imx@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [RESEND] net: phy: fix NULL pointer dereference in phy_polling_mode()
Date: Thu, 7 Aug 2025 14:55:08 +0200	[thread overview]
Message-ID: <39d7c6be-c3e9-4c2f-b814-e0b2e838ad41@lunn.ch> (raw)
In-Reply-To: <3mkwdhodm4zl3t6zsavcrrkuawvd3qjxtdvhxwi6gwe42ic7rs@tevlpedpwlag>

> diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
> index 9b0318fb50b5..9fba1cb17134 100644
> --- a/drivers/net/usb/asix_devices.c
> +++ b/drivers/net/usb/asix_devices.c
> @@ -676,6 +676,7 @@ static int ax88772_init_mdio(struct usbnet *dev)
>         priv->mdio->read = &asix_mdio_bus_read;
>         priv->mdio->write = &asix_mdio_bus_write;
>         priv->mdio->name = "Asix MDIO Bus";
> +       priv->mdio->phy_mask = ~BIT(priv->phy_addr);
>         /* mii bus name is usb-<usb bus number>-<usb device number> */
>         snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d",
>                  dev->udev->bus->busnum, dev->udev->devnum);
> 
> Is this the right thing to do?

This is what i was trying to do, i just put it in the wrong place
because i had the wrong device.

ax88772_init_phy() will only use the PHY at address priv->phy_addr, so
this appears to be safe.

The alternative is to have a custom asix_mdio_read() for this device,
which returns -ENODEV if the phy_id being read does not equal
priv->phy_addr. That will also prevent these extra PHYs from being
created.

	Andrew

  parent reply	other threads:[~2025-08-07 12:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06  8:29 Xu Yang
2025-08-06  8:45 ` Russell King (Oracle)
2025-08-06  8:56   ` Xu Yang
2025-08-06 13:01     ` Russell King (Oracle)
2025-08-06 14:14       ` Xu Yang
2025-08-06 15:01         ` Andrew Lunn
2025-08-06 16:47           ` Russell King (Oracle)
2025-08-07  9:23             ` Xu Yang
2025-08-07 11:21               ` Xu Yang
2025-08-07 11:47                 ` Russell King (Oracle)
2025-08-07 12:45                   ` Oleksij Rempel
2025-08-07 12:58                     ` Andrew Lunn
2025-08-07 14:02                       ` Oleksij Rempel
2025-08-08 10:26                     ` Xu Yang
2025-08-08 10:17                   ` Xu Yang
2025-08-07 12:55                 ` Andrew Lunn [this message]
2025-08-07  9:10           ` Xu Yang

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=39d7c6be-c3e9-4c2f-b814-e0b2e838ad41@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=hkallweit1@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=xu.yang_2@nxp.com \
    /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

all inboxes | Powered by JetHome®