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 v2 01/12] usb: gadget: amd5536udc: rewrite init_dma_pools
Date: Tue, 22 Sep 2015 18:54:26 +0530 [thread overview]
Message-ID: <1442928277-11022-2-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In-Reply-To: <1442928277-11022-1-git-send-email-sudipm.mukherjee@gmail.com>
A rewrite of init_dma_pools() with proper error handling.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
drivers/usb/gadget/udc/amd5536udc.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c
index 175ca93..38a6858 100644
--- a/drivers/usb/gadget/udc/amd5536udc.c
+++ b/drivers/usb/gadget/udc/amd5536udc.c
@@ -3169,8 +3169,7 @@ static int init_dma_pools(struct udc *dev)
sizeof(struct udc_data_dma), 0, 0);
if (!dev->data_requests) {
DBG(dev, "can't get request data pool\n");
- retval = -ENOMEM;
- goto finished;
+ return -ENOMEM;
}
/* EP0 in dma regs = dev control regs */
@@ -3182,14 +3181,14 @@ static int init_dma_pools(struct udc *dev)
if (!dev->stp_requests) {
DBG(dev, "can't get stp request pool\n");
retval = -ENOMEM;
- goto finished;
+ goto err_create_dma_pool;
}
/* setup */
td_stp = dma_pool_alloc(dev->stp_requests, GFP_KERNEL,
&dev->ep[UDC_EP0OUT_IX].td_stp_dma);
if (td_stp == NULL) {
retval = -ENOMEM;
- goto finished;
+ goto err_alloc_dma;
}
dev->ep[UDC_EP0OUT_IX].td_stp = td_stp;
@@ -3198,12 +3197,20 @@ static int init_dma_pools(struct udc *dev)
&dev->ep[UDC_EP0OUT_IX].td_phys);
if (td_data == NULL) {
retval = -ENOMEM;
- goto finished;
+ goto err_alloc_phys;
}
dev->ep[UDC_EP0OUT_IX].td = td_data;
return 0;
-finished:
+err_alloc_phys:
+ dma_pool_free(dev->stp_requests, dev->ep[UDC_EP0OUT_IX].td_stp,
+ dev->ep[UDC_EP0OUT_IX].td_stp_dma);
+err_alloc_dma:
+ dma_pool_destroy(dev->stp_requests);
+ dev->stp_requests = NULL;
+err_create_dma_pool:
+ dma_pool_destroy(dev->data_requests);
+ dev->data_requests = NULL;
return retval;
}
--
1.9.1
next prev parent reply other threads:[~2015-09-22 13:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 13:24 [PATCH v2 00/12] usb: gadget: amd5536udc: fix memory leaks Sudip Mukherjee
2015-09-22 13:24 ` Sudip Mukherjee [this message]
2015-09-22 13:24 ` [PATCH v2 02/12] usb: gadget: amd5536udc: fix error path Sudip Mukherjee
2015-09-22 14:37 ` Felipe Balbi
2015-09-22 14:42 ` Sudip Mukherjee
2015-09-22 14:59 ` Sudip Mukherjee
2015-09-22 15:19 ` Felipe Balbi
2015-09-22 16:32 ` Sudip Mukherjee
2015-09-30 13:51 ` Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 03/12] usb: gadget: amd5536udc: use WARN_ON Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 04/12] usb: gadget: amd5536udc: use free_dma_pools Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 05/12] usb: gadget: amd5536udc: remove unnecessary conditions Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 06/12] usb: gadget: amd5536udc: remove forward declaration of udc_probe Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 07/12] usb: gadget: amd5536udc: remove forward declaration of udc_remote_wakeup Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 08/12] usb: gadget: amd5536udc: remove forward declaration of udc_create_dma_chain Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 09/12] usb: gadget: amd5536udc: remove forward declaration of udc_free_dma_chain Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 10/12] usb: gadget: amd5536udc: remove forward declaration of udc_pci_* Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 11/12] usb: gadget: amd5536udc: remove forward declaration of udc_basic_init Sudip Mukherjee
2015-09-22 13:24 ` [PATCH v2 12/12] usb: gadget: amd5536udc: NULL comparison Sudip Mukherjee
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=1442928277-11022-2-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;
as well as URLs for NNTP newsgroup(s).