Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935962AbcLUOic (ORCPT ); Wed, 21 Dec 2016 09:38:32 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:35482 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759535AbcLUOiX (ORCPT ); Wed, 21 Dec 2016 09:38:23 -0500 MIME-Version: 1.0 In-Reply-To: <20161221133315.GA13517@sudip-tp> References: <1482101091-3969-1-git-send-email-sudipm.mukherjee@gmail.com> <20161221133315.GA13517@sudip-tp> From: Shuah Khan Date: Wed, 21 Dec 2016 07:38:21 -0700 Message-ID: Subject: Re: [PATCH] usbip: vudc: check for NULL before use To: Sudip Mukherjee Cc: Shuah Khan , Valentina Manea , Greg Kroah-Hartman , LKML , linux-usb@vger.kernel.org, Shuah Khan , Shuah Khan Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1690 Lines: 59 Hi Sudip, On Wed, Dec 21, 2016 at 6:33 AM, Sudip Mukherjee wrote: > On Tue, Dec 20, 2016 at 07:31:44AM -0700, Shuah Khan wrote: >> On 12/18/2016 03:44 PM, Sudip Mukherjee wrote: >> > to_vep() is doing a container_of() on _ep. It is better to do the NULL >> > check first and then use it. >> > >> > Signed-off-by: Sudip Mukherjee >> > --- >> > drivers/usb/usbip/vudc_dev.c | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c >> > index 968471b..32ea604 100644 >> > --- a/drivers/usb/usbip/vudc_dev.c >> > +++ b/drivers/usb/usbip/vudc_dev.c >> > @@ -388,10 +388,10 @@ static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req) >> > unsigned long flags; >> > int ret = 0; >> > >> > - ep = to_vep(_ep); >> > if (!_ep) >> > return -EINVAL; >> >> Hmm. Linus's latest checks _ep and _req. Are you sure you are working >> with the latest tree? > > I checked with next-20161221 and its still there. This is for vep_dequeue() - Are you sure both linux-next and Linus's tree show the following: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/usbip/vudc_dev.c static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req) { struct vep *ep; struct vrequest *req; struct vudc *udc; struct vrequest *lst; unsigned long flags; int ret = -EINVAL; if (!_ep || !_req) return ret; ep = to_vep(_ep); req = to_vrequest(_req); udc = req->udc; if (!udc->driver) return -ESHUTDOWN; There are other routines in this file that don't check null. I am confused. thanks, -- Shuah