From patchwork Wed May 15 09:51:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 16940 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D04052396C for ; Wed, 15 May 2013 09:53:30 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id hf12sf870887vcb.10 for ; Wed, 15 May 2013 02:52:54 -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=NkMchyrfqaiAdQ7DbbNIP7J7cgdKj2s8MCIGW+SVvnM=; b=XCIumH29UqXzhfolOAS0EawpOo7/0Y6RqcilqGsHjaIC/A6kYo4fTIBKCweu8B4hjN yuU9Mj8EwAAfIVASwOIRKDU+/o3cp7Gk0OOhhH0wKHownI2qW3C6LN3zlxGnQee7X9lG s2UqF1pU/XSL1uv9fR2WVM+Dszvu1u/w51HK7MmXKqMcyxTiQpy1pyHg6lvItf+Sksla 5FSVH1nYh4f/rQlx/zOG2ZBCvoLy4NvrL9Y9IJ7FaHCE4V80NRl5/9H/z5FAac0GJZtn uNWWIljHkQPGas+Oa+AGBdc8EY66FPwiL5oo+So4dUycW4kp+AmTgBe6W1MZcvpJPUbt RoAg== X-Received: by 10.224.200.202 with SMTP id ex10mr23010723qab.8.1368611574169; Wed, 15 May 2013 02:52:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.17.70 with SMTP id m6ls695105qed.30.gmail; Wed, 15 May 2013 02:52:54 -0700 (PDT) X-Received: by 10.220.96.17 with SMTP id f17mr23987914vcn.58.1368611573946; Wed, 15 May 2013 02:52:53 -0700 (PDT) Received: from mail-vb0-x233.google.com (mail-vb0-x233.google.com [2607:f8b0:400c:c02::233]) by mx.google.com with ESMTPS id bs2si1051935veb.5.2013.05.15.02.52.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 May 2013 02:52:53 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::233 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::233; Received: by mail-vb0-f51.google.com with SMTP id x16so283389vbf.10 for ; Wed, 15 May 2013 02:52:53 -0700 (PDT) X-Received: by 10.221.4.131 with SMTP id oc3mr1803526vcb.49.1368611573776; Wed, 15 May 2013 02:52:53 -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.220.217.15 with SMTP id hk15csp11363vcb; Wed, 15 May 2013 02:52:53 -0700 (PDT) X-Received: by 10.180.182.229 with SMTP id eh5mr13320492wic.6.1368611572612; Wed, 15 May 2013 02:52:52 -0700 (PDT) Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [2a00:1450:400c:c05::233]) by mx.google.com with ESMTPS id v10si517938wjw.209.2013.05.15.02.52.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 May 2013 02:52:52 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::233 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c05::233; Received: by mail-wi0-f179.google.com with SMTP id hq7so1418261wib.0 for ; Wed, 15 May 2013 02:52:52 -0700 (PDT) X-Received: by 10.194.93.39 with SMTP id cr7mr2786561wjb.41.1368611572203; Wed, 15 May 2013 02:52:52 -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 q13sm2898210wie.8.2013.05.15.02.52.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 May 2013 02:52:51 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, balbi@ti.com, linux-usb@vger.kernel.org, linux-crypto@vger.kernel.org, davem@davemloft.net, herbert@gondor.apana.org.au, vinod.koul@intel.com Cc: arnd@arndb.de, linus.walleij@stericsson.com, srinidhi.kasagar@stericsson.com, Lee Jones Subject: [PATCH 23/39] usb: musb: ux500: harden checks for platform data Date: Wed, 15 May 2013 10:51:46 +0100 Message-Id: <1368611522-9984-24-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1368611522-9984-1-git-send-email-lee.jones@linaro.org> References: <1368611522-9984-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQmhJVWkuEEDtVIk9YftjIKdbzOl2qzrZ2qVVdvdJcw5Rx7kYZYMq4nok8coScGmxTAJXE38 X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::233 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 382291b..4bd5400 100644 --- a/drivers/usb/musb/ux500_dma.c +++ b/drivers/usb/musb/ux500_dma.c @@ -289,7 +289,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; @@ -299,14 +299,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; @@ -339,7 +344,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; }