Re: [PATCH -mm] drivers/usb/core/config.c: kzalloc(0, ..)

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel,gmane.linux.kernel
Message-ID <[email protected]>
On Tue, 8 May 2007, Greg KH wrote:

> >  The problem was in drivers/usb/core/config.c in function 
> >  usb_parse_interface:
> >  ---
> >  num_ep = num_ep_orig = alt->desc.bNumEndpoints;
> >  ...
> >  len = sizeof(struct usb_host_endpoint) * num_ep;
> >  alt->endpoint = kzalloc(len, GFP_KERNEL);
> >  ---
> > 
> >  num_ep can be 0, as it was in my case, so following patch makes this
> >  situation more obvious
> >  and clear.

How about instead just doing:

+	num_ep = max(num_ep, 1);
 	len = sizeof(struct usb_host_endpoint) * num_ep;

Also, wasn't it true at one point that it was legal to call kmalloc() with 
a length of 0?  ISTR seeing somewhere that it's true for regular malloc().

Alan Stern


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.