Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030401AbXEHP5V (ORCPT ); Tue, 8 May 2007 11:57:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1030354AbXEHP5T (ORCPT ); Tue, 8 May 2007 11:57:19 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:33034 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S966433AbXEHP5M (ORCPT ); Tue, 8 May 2007 11:57:12 -0400 Date: Tue, 8 May 2007 11:57:07 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Dan Kruchinin cc: Greg KH , Andrew Morton , Kernel development list , USB development list Subject: Re: [linux-usb-devel] [PATCH -mm] drivers/usb/core/config.c: kzalloc(0, ..) In-Reply-To: <20070508141453.GA12771@kroah.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 948 Lines: 30 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/