Re: [PATCH v3 2/2] net: phy: add marvell usb to mdio controller
From: Greg KH <gregkh@linuxfoundation.org>
Date: 2020-03-22 11:10:55
Also in:
linux-usb
From: Greg KH <gregkh@linuxfoundation.org>
Date: 2020-03-22 11:10:55
Also in:
linux-usb
On Sun, Mar 22, 2020 at 10:09:28AM +0100, Tobias Waldekranz wrote:
On Sun Mar 22, 2020 at 8:40 AM, Greg KH wrote:quoted
From a USB point of view, it looks sane, only one question:Great, thanks for the review.quoted
quoted
+static int mvusb_mdio_probe(struct usb_interface *interface, + const struct usb_device_id *id) +{ + struct device *dev = &interface->dev; + struct mvusb_mdio *mvusb; + struct mii_bus *mdio; + + mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb));You allocate a bigger buffer here than the original pointer thinks it is pointing to?Yes. I've seen this pattern in a couple of places in the kernel, e.g. alloc_netdev also does this. The object is extended with the requested size, and the offset is stored somewhere for later use by the driver.quoted
quoted
+ if (!mdio) + return -ENOMEM; + + mvusb = mdio->priv;And then you set this pointer here?...in this case in the priv member. https://code.woboq.org/linux/linux/drivers/net/phy/mdio_bus.c.html#143
Ok, just wanted to make sure :) Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>