From patchwork Fri Mar 8 02:27:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Baltieri X-Patchwork-Id: 15270 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 689AB23E2E for ; Fri, 8 Mar 2013 02:27:24 +0000 (UTC) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by fiordland.canonical.com (Postfix) with ESMTP id 17036A1917B for ; Fri, 8 Mar 2013 02:27:24 +0000 (UTC) Received: by mail-ve0-f174.google.com with SMTP id pb11so921522veb.33 for ; Thu, 07 Mar 2013 18:27:23 -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=CtVCE1zblU6PBSARXeR7iG8RajofK9B/JXekt3cz5qFvpCK4h4SE+T5M+iKtuQcz7Z dlI5RIC+6+kkC4wJVFzESHPS9E5rvix8GMI6p+29+hKFegVUMu+860arwrNnWxcgEGqV HXryMHpUZHuPlDyFCNN6jnVf1kMxDExV+SqIzHAG6Zw/UkTB0/qQ4Sb7mjbEFRzT9vJ4 eKYv5XFcpLEoldI9HDcAcoWgWLyWJavDgjAdrUqyuYQ9F+nlI5VYkc/tgDmNC2e5Mf1Q nT2qx1H1IsBFq1YkKOZQBJ2beNA4WXYzJ7h453ZrKV/jayAuRWp3i/WQRTKzaLjsgQ5j rLig== X-Received: by 10.58.48.166 with SMTP id m6mr209519ven.59.1362709643529; Thu, 07 Mar 2013 18:27:23 -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.127.98 with SMTP id nf2csp98701veb; Thu, 7 Mar 2013 18:27:23 -0800 (PST) X-Received: by 10.66.180.162 with SMTP id dp2mr1653357pac.67.1362709642524; Thu, 07 Mar 2013 18:27:22 -0800 (PST) Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by mx.google.com with ESMTPS id tm7si3833449pbc.210.2013.03.07.18.27.22 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 07 Mar 2013 18:27:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.54 is neither permitted nor denied by best guess record for domain of fabio.baltieri@linaro.org) client-ip=209.85.220.54; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.54 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-pa0-f54.google.com with SMTP id fa10so925290pad.27 for ; Thu, 07 Mar 2013 18:27:22 -0800 (PST) X-Received: by 10.66.234.97 with SMTP id ud1mr1613020pac.90.1362709642037; Thu, 07 Mar 2013 18:27:22 -0800 (PST) Received: from localhost ([118.143.64.134]) by mx.google.com with ESMTPS id xx10sm4303305pac.15.2013.03.07.18.27.18 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 07 Mar 2013 18:27:20 -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 v2 1/5] usb: musb: ux500_dma: add missing MEM resource check Date: Fri, 8 Mar 2013 10:27:05 +0800 Message-Id: <1362709629-27238-2-git-send-email-fabio.baltieri@linaro.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1362709629-27238-1-git-send-email-fabio.baltieri@linaro.org> References: <1362709629-27238-1-git-send-email-fabio.baltieri@linaro.org> X-Gm-Message-State: ALoCoQmcN7okdVJK+FOHIGWFiNP2JIMqMdmjksILYcmJkEOmaizR7i6di96kZNWgruDx0d9s0Yfl 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; }