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] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 9 Sep 2008 14:56:19 +0100
From:	Steve.Glendinning@...c.com
To:	Ben Hutchings <bhutchings@...arflare.com>
Cc:	Catalin Marinas <catalin.marinas@....com>,
	David Brownell <dbrownell@...rs.sourceforge.net>,
	ian.saturley@...c.com, linux-usb@...r.kernel.org,
	netdev@...r.kernel.org
Subject: Re: [PATCH 1/1] SMSC LAN9500 USB2.0 10/100 ethernet adapter driver

Hi Ben,

Thanks for your feedback, many really good points there.

> > +static int smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 
*data)
> > +{
> > +   u32 *buf = kmalloc(4, GFP_KERNEL);
> > +   int ret;
> > +
> > +   BUG_ON(!dev);
> > +
> > +   if (!buf)
> > +      return -ENOMEM;
> > +
> > +   ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> > +      USB_VENDOR_REQUEST_READ_REGISTER,
> > +      USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
> > +      00, index, buf, 4, USB_CTRL_GET_TIMEOUT);
> > +
> > +   if (unlikely(ret < 0))
> > +      SMSC_WARNING("Failed to read register index 0x%08x", index);
> > +
> > +   le32_to_cpus(buf);
> > +   *data = *buf;
> > +   kfree(buf);
> > +
> > +   return ret;
> > +}
> 
> Why are you allocating a buffer on the heap?  What's wrong with
> 
> static int smsc95xx_read_reg(struct usbnet *dev, u32 index, u32 *data)
> {
>    int ret;
> 
>    BUG_ON(!dev);
> 
>    ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
>       USB_VENDOR_REQUEST_READ_REGISTER,
>       USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
>       00, index, data, 4, USB_CTRL_GET_TIMEOUT);
> 
>    if (unlikely(ret < 0))
>       SMSC_WARNING("Failed to read register index 0x%08x", index);
> 
>    le32_to_cpus(data);
> 
>    return ret;
> }
> 
> ?

For the same reason dm9601.c and asix.c do - we're not allowed to do
usb transfers of data on stack.  It works on some architectures, but
breaks badly on others.

Peter Korsgaard fixed dm9601 for it here:

http://kerneltrap.org/mailarchive/linux-netdev/2008/7/14/2452854

As with dm9601, this is only used for config registers - nothing in
the fast path.

Regards,
--
Steve Glendinning
SMSC GmbH
m: +44 777 933 9124
e: steve.glendinning@...c.com
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ