From patchwork Fri May 3 14:32:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 16678 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0342223905 for ; Fri, 3 May 2013 14:35:19 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id w6sf2446548ggk.0 for ; Fri, 03 May 2013 07:35:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=ywpnyRPbbzL8NAiYPuRER964gcfkSVKGEmnixcmgzzw=; b=PgffUclygUCpSSeA3C6WxjFCrRuCAgz3zOoZLDiNAhCHDLaiubqOmDDsyLzZ2roBKo CvQVcK6S6HdBAE2uQn9qhAAPsc6Z38Iad+75BbPr5ry6RI+Dt4VWjN7YzFzJD9NYn7uQ n9NcQAj96bGk8/5mce7dQV0zwWSe1mnL69gB68EggJiTKPyTI7DaRPBohsvhNyd0BtsG ahfBe4iLjQRW2JlH1hWIGOsSAXMXXmjY1tqHyY8KO0WWsiUS+3lgx/JbErM76luLuxR+ 6AeEp8OJxs7eIa5/pjxwiY4ndlXJUplz2uxPxf4Oyhxxmk6AhziNOU2U9HH1JKqEgbzq CKOg== X-Received: by 10.236.80.106 with SMTP id j70mr8633110yhe.11.1367591710179; Fri, 03 May 2013 07:35:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.28.70 with SMTP id z6ls1437375qeg.91.gmail; Fri, 03 May 2013 07:35:10 -0700 (PDT) X-Received: by 10.58.143.77 with SMTP id sc13mr3734038veb.21.1367591709971; Fri, 03 May 2013 07:35:09 -0700 (PDT) Received: from mail-vb0-x232.google.com (mail-vb0-x232.google.com [2607:f8b0:400c:c02::232]) by mx.google.com with ESMTPS id by3si1557019vdc.4.2013.05.03.07.35.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 07:35:09 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::232; Received: by mail-vb0-f50.google.com with SMTP id w16so1400006vbb.37 for ; Fri, 03 May 2013 07:35:09 -0700 (PDT) X-Received: by 10.52.66.101 with SMTP id e5mr3174527vdt.57.1367591709894; Fri, 03 May 2013 07:35:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp25260veb; Fri, 3 May 2013 07:35:09 -0700 (PDT) X-Received: by 10.180.13.166 with SMTP id i6mr40979664wic.21.1367591708755; Fri, 03 May 2013 07:35:08 -0700 (PDT) Received: from mail-we0-x231.google.com (mail-we0-x231.google.com [2a00:1450:400c:c03::231]) by mx.google.com with ESMTPS id a11si3591580wjx.248.2013.05.03.07.35.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 07:35:08 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::231 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c03::231; Received: by mail-we0-f177.google.com with SMTP id u3so1350583wey.8 for ; Fri, 03 May 2013 07:35:08 -0700 (PDT) X-Received: by 10.180.108.3 with SMTP id hg3mr13763428wib.17.1367591708267; Fri, 03 May 2013 07:35:08 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPSA id o3sm17516019wia.2.2013.05.03.07.35.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 03 May 2013 07:35:07 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, srinidhi.kasagar@stericsson.com, Lee Jones , Felipe Balbi , linux-usb@vger.kernel.org Subject: [PATCH 47/63] usb: musb: ux500: harden checks for platform data Date: Fri, 3 May 2013 15:32:33 +0100 Message-Id: <1367591569-32197-48-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1367591569-32197-1-git-send-email-lee.jones@linaro.org> References: <1367591569-32197-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQn0t0dIhQVN3Q7EfJmqFzmTlADOSTrfGtaz5si0isUEdw1WflauMye4ASwVS5+dvFPxjUiH X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::232 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In its current state, the ux500-musb driver uses platform data pointers blindly with no prior checking. If no platform data pointer is passed this will Oops the kernel. In this patch we ensure platform data and board data are present prior to using them. Cc: Felipe Balbi Cc: linux-usb@vger.kernel.org Acked-by: Fabio Baltieri Signed-off-by: Lee Jones --- drivers/usb/musb/ux500_dma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c index c75e07a..8d5128d 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c @@ -287,7 +287,7 @@ static int ux500_dma_controller_start(struct dma_controller *c) struct musb *musb = controller->private_data; struct device *dev = musb->controller; struct musb_hdrc_platform_data *plat = dev->platform_data; - struct ux500_musb_board_data *data = plat->board_data; + struct ux500_musb_board_data *data; struct dma_channel *dma_channel = NULL; u32 ch_num; u8 dir; @@ -297,14 +297,19 @@ static int ux500_dma_controller_start(struct dma_controller *c) struct ux500_dma_channel *channel_array; dma_cap_mask_t mask; + if (!plat) { + dev_err(musb->controller, "No platform data\n"); + return -EINVAL; + } + data = plat->board_data; dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); /* Prepare the loop for RX channels */ channel_array = controller->rx_channel; - param_array = data->dma_rx_param_array; + param_array = data ? data->dma_rx_param_array : NULL; for (dir = 0; dir < 2; dir++) { for (ch_num = 0; @@ -337,7 +342,7 @@ static int ux500_dma_controller_start(struct dma_controller *c) /* Prepare the loop for TX channels */ channel_array = controller->tx_channel; - param_array = data->dma_tx_param_array; + param_array = data ? data->dma_tx_param_array : NULL; is_tx = 1; }