lkml.org 
[lkml]   [2007]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [linux-usb-devel] [PATCH -mm] drivers/usb/core/config.c: kzalloc(0, ..)
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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-05-08 17:59    [W:0.135 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site