Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754471AbcDKOot (ORCPT ); Mon, 11 Apr 2016 10:44:49 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:48414 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1754359AbcDKOor (ORCPT ); Mon, 11 Apr 2016 10:44:47 -0400 Date: Mon, 11 Apr 2016 10:44:45 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: chunfeng yun cc: Felipe Balbi , Greg Kroah-Hartman , , , , Subject: Re: [PATCH] usb: core: buffer: avoid NULL pointer dereferrence In-Reply-To: <1460358968.10419.26.camel@mhfsdcap03> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1055 Lines: 27 On Mon, 11 Apr 2016, chunfeng yun wrote: > On Mon, 2016-04-11 at 08:07 +0300, Felipe Balbi wrote: > > Hi, > > > > chunfeng yun writes: > > > On Fri, 2016-04-08 at 07:07 -0700, Greg Kroah-Hartman wrote: > > >> On Fri, Apr 08, 2016 at 05:08:03PM +0800, Chunfeng Yun wrote: > > >> > NULL pointer dereferrence will happen when class driver > > >> > wants to allocate zero length buffer and pool_max[0] > > >> > can't be used, so skip reserved pool in this case. > > >> > > >> Why would a driver want to allocate a 0 length buffer? What driver does > > >> this? > > > It's misc/usbtest.c > > > > that'll do what you ask it to do with the userspace tool testusb. Are > > you trying to pass a size of 0 ? > > > No, I just ran "testusb -t10" which called test_ctrl_queue(). > In this function, sub-case 8 passed a parameter @len as 0 to > simple_alloc_urb(), and then it tried to allocate a 0-length buffer. That should be easy enough to fix. Just skip the calls that allocate the buffer if the length would be 0. Alan Stern