From patchwork Thu Feb 28 10:38:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15150 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A523C23E27 for ; Thu, 28 Feb 2013 10:39:20 +0000 (UTC) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by fiordland.canonical.com (Postfix) with ESMTP id 57B23A186E5 for ; Thu, 28 Feb 2013 10:39:20 +0000 (UTC) Received: by mail-vc0-f182.google.com with SMTP id fl17so1097807vcb.41 for ; Thu, 28 Feb 2013 02:39:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=yV7w0YpwI0gFpLSWgEByQy9Rq7yQwiUYTSat/DcC8F0=; b=BXI3PfuUc+RnhUFWi2uOoURTzlSAyiCbYH+3MJRrNSKLJILUWt+LUG0UtoOVXa6T1t Wi5wFMhT1dIsABo6KLb7g+J/rKvDrwUVE9sAAf5ArtVRErO7IIjB7sEJw00vqK15RSe0 t+bCCmFZrjMU7dwrWumjrLR6XK5uNt4Vw4ZnVm0XMIxgL7m7MK0eHuVaWBLKShkX8cmu 6xJ4RqgiwzH2vtyBM7L7DAEeRfNiEg9H4nIKe+xlALXb2uN75lrXAc9mpJz8s1eAPVVA vhETXzZDLWzYKROSN4+g1ij0HOSOU7dX7dTOibJZM0upz2cZ/xv4jhzThOLkvQ/ynWz1 BBVQ== X-Received: by 10.52.177.163 with SMTP id cr3mr2028838vdc.94.1362047959828; Thu, 28 Feb 2013 02:39:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp218157veb; Thu, 28 Feb 2013 02:39:19 -0800 (PST) X-Received: by 10.181.11.164 with SMTP id ej4mr9599640wid.29.1362047958634; Thu, 28 Feb 2013 02:39:18 -0800 (PST) Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by mx.google.com with ESMTPS id kx1si3617028wjb.209.2013.02.28.02.39.18 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Feb 2013 02:39:18 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.176 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=209.85.212.176; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.176 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) smtp.mail=fabio.baltieri@linaro.org Received: by mail-wi0-f176.google.com with SMTP id hm14so7486663wib.9 for ; Thu, 28 Feb 2013 02:39:18 -0800 (PST) X-Received: by 10.180.84.8 with SMTP id u8mr7515292wiy.1.1362047958239; Thu, 28 Feb 2013 02:39:18 -0800 (PST) Received: from localhost ([2a01:2003:1:1e91:8e70:5aff:feac:ad8]) by mx.google.com with ESMTPS id ek4sm32487177wib.11.2013.02.28.02.39.12 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 28 Feb 2013 02:39:17 -0800 (PST) From: Fabio Baltieri To: Felipe Balbi Cc: Linus Walleij , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Virupax Sadashivpetimath , Fabio Baltieri Subject: [PATCH 1/5] usb: musb: ux500_dma: add missing MEM resource check Date: Thu, 28 Feb 2013 11:38:50 +0100 Message-Id: <1362047934-22337-2-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1362047934-22337-1-git-send-email-fabio.baltieri@linaro.org> References: <1362047934-22337-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQkGtdoL6CgnjEl/wFlNU/JNlDBuvkSu6vlYuDY+Au79Uw0zy0yYiBVwd2c0xYvUGFevTgnb From: Virupax Sadashivpetimath Fix dma_controller_create() fail path in case memory resource is missing. Acked-by: Linus Walleij Signed-off-by: Virupax Sadashivpetimath Signed-off-by: Fabio Baltieri --- drivers/usb/musb/ux500_dma.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index 360c99c..6e3db71 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c @@ -372,12 +372,17 @@ struct dma_controller *dma_controller_create(struct musb *musb, controller = kzalloc(sizeof(*controller), GFP_KERNEL); if (!controller) - return NULL; + goto kzalloc_fail; controller->private_data = musb; /* Save physical address for DMA controller. */ iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iomem) { + dev_err(musb->controller, "no memory resource defined\n"); + goto plat_get_fail; + } + controller->phy_base = (dma_addr_t) iomem->start; controller->controller.start = ux500_dma_controller_start; @@ -389,4 +394,9 @@ struct dma_controller *dma_controller_create(struct musb *musb, controller->controller.is_compatible = ux500_dma_is_compatible; return &controller->controller; + +plat_get_fail: + kfree(controller); +kzalloc_fail: + return NULL; }