From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752061AbbIKOVN (ORCPT ); Fri, 11 Sep 2015 10:21:13 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36798 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750804AbbIKOVM (ORCPT ); Fri, 11 Sep 2015 10:21:12 -0400 Date: Fri, 11 Sep 2015 19:51:01 +0530 From: Sudip Mukherjee To: Felipe Balbi Cc: David Cohen , Thomas Dahlmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-geode@lists.infradead.org, linux-usb@vger.kernel.org Subject: Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference Message-ID: <20150911142101.GA19150@sudip-pc> References: <1441366943-9390-1-git-send-email-sudipm.mukherjee@gmail.com> <20150910180334.GA10760@psi-dev26.jf.intel.com> <20150911100256.GA15689@sudip-pc> <20150911132834.GB17326@saruman.tx.rr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150911132834.GB17326@saruman.tx.rr.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 11, 2015 at 08:28:34AM -0500, Felipe Balbi wrote: > Hi, > > On Fri, Sep 11, 2015 at 03:32:56PM +0530, Sudip Mukherjee wrote: > > On Thu, Sep 10, 2015 at 11:03:34AM -0700, David Cohen wrote: > no, the check is pointless. Most of these are. Just look at your probe() > and you'll see that if dev->virt_addr is NULL (meaning ioremap_nocache() > failed) you exit from probe() with error. The driver doesn't probe at > all. So you can be sure that by remove, dev->regs is valid. > > BTW, if probe fails, you have a TON of leaked resources!! You don't kfree() > dev, you don't pci_disable_device(), you don't release_mem_region(), you > don't iounmap() virt_addr, you don't free_irq(). > > Also the iounmap() call in remove is wrong. You ioremapped > dev->virt_addr but iounmap() dev->regs. Are you SURE that's ok ? > > Man, what a mess! You gotta fix that up. :( Yes, total mess. I am on it. BTW, while I am fixing it can i also include a patch which will rearrange the functions and remove the forward declarations? regards sudip