mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Thomas Dahlmann <dahlmann.thomas@arcor.de>,
	Felipe Balbi <balbi@ti.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, linux-geode@lists.infradead.org,
	linux-usb@vger.kernel.org,
	Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH 00/16] usb: gadget: amd5536udc: fix memory leaks
Date: Mon, 14 Sep 2015 20:42:47 +0530	[thread overview]
Message-ID: <1442243583-24741-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)

This amd5536udc was a complete mess. The major problems that i could
find are:

1) if udc_pci_probe() fails in any stage then it just calls the
udc_pci_remove() to handle error. And udc_pci_remove() works with
struct udc *dev which we get from pci_get_drvdata(pdev). But we do the
pci_set_drvdata(pdev, dev) almost at the end of probe. So basically
incase of error we are handling the error by dereferencing a NULL
pointer.

2) udc_pci_remove() does a BUG_ON(dev->driver != NULL) and dev->driver
will be set only if probe is success. So that means if probe fails then
probe will call udc_pci_remove() for error handling and udc_pci_remove()
will inturn halts the kernel by calling BUG().

And apart from these numerous memory leaks and not releasing of
resources. Here comes a rewrite of few of the functions in an
attempt to fix these.

regards
sudip

Sudip Mukherjee (16):
  usb: gadget: amd5536udc: introduce free_dma_pools
  usb: gadget: amd5536udc: rewrite init_dma_pools
  usb: gadget: amd5536udc: rewrite udc_pci_probe
  usb: gadget: amd5536udc: use WARN_ON
  usb: gadget: amd5536udc: use free_dma_pools
  usb: gadget: amd5536udc: remove unnecessary conditions
  usb: gadget: amd5536udc: unmap virt_addr
  usb: gadget: amd5536udc: remove forward declaration of udc_probe
  usb: gadget: amd5536udc: remove forward declaration of udc_remote_wakeup
  usb: gadget: amd5536udc: remove forward declaration of udc_create_dma_chain
  usb: gadget: amd5536udc: remove forward declaration of udc_free_dma_chain
  usb: gadget: amd5536udc: remove forward declaration of udc_pci_*
  usb: gadget: amd5536udc: remove forward declaration of udc_basic_init
  usb: gadget: amd5536udc: NULL comparison
  usb: gadget: amd5536udc: remove multiple blank lines
  usb: gadget: amd5536udc: match alignment

 drivers/usb/gadget/udc/amd5536udc.c | 797 ++++++++++++++++++------------------
 1 file changed, 390 insertions(+), 407 deletions(-)

-- 
1.9.1


             reply	other threads:[~2015-09-14 15:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 15:12 Sudip Mukherjee [this message]
2015-09-14 15:12 ` [PATCH 01/16] usb: gadget: amd5536udc: introduce free_dma_pools Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 02/16] usb: gadget: amd5536udc: rewrite init_dma_pools Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 03/16] usb: gadget: amd5536udc: rewrite udc_pci_probe Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 04/16] usb: gadget: amd5536udc: use WARN_ON Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 05/16] usb: gadget: amd5536udc: use free_dma_pools Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 06/16] usb: gadget: amd5536udc: remove unnecessary conditions Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 07/16] usb: gadget: amd5536udc: unmap virt_addr Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 08/16] usb: gadget: amd5536udc: remove forward declaration of udc_probe Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 09/16] usb: gadget: amd5536udc: remove forward declaration of udc_remote_wakeup Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 10/16] usb: gadget: amd5536udc: remove forward declaration of udc_create_dma_chain Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 11/16] usb: gadget: amd5536udc: remove forward declaration of udc_free_dma_chain Sudip Mukherjee
2015-09-14 15:12 ` [PATCH 12/16] usb: gadget: amd5536udc: remove forward declaration of udc_pci_* Sudip Mukherjee
2015-09-14 15:13 ` [PATCH 13/16] usb: gadget: amd5536udc: remove forward declaration of udc_basic_init Sudip Mukherjee
2015-09-14 15:13 ` [PATCH 14/16] usb: gadget: amd5536udc: NULL comparison Sudip Mukherjee
2015-09-14 15:13 ` [PATCH 15/16] usb: gadget: amd5536udc: remove multiple blank lines Sudip Mukherjee
2015-09-14 15:13 ` [PATCH 16/16] usb: gadget: amd5536udc: match alignment Sudip Mukherjee
2015-09-18 18:39 ` [PATCH 00/16] usb: gadget: amd5536udc: fix memory leaks Felipe Balbi
2015-09-19  3:54   ` Sudip Mukherjee
2015-09-20  8:12     ` Sudip Mukherjee
2015-09-20 16:17       ` Felipe Balbi
2015-09-21 12:48         ` Sudip Mukherjee
2015-09-21 14:42           ` Felipe Balbi
2015-09-20 16:16     ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442243583-24741-1-git-send-email-sudipm.mukherjee@gmail.com \
    --to=sudipm.mukherjee@gmail.com \
    --cc=balbi@ti.com \
    --cc=dahlmann.thomas@arcor.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-geode@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®