aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2013-05-15 05:51:46 -0400
committerLinus Walleij <linus.walleij@linaro.org>2013-06-04 05:12:04 -0400
commit5f6091a023ca435c49467348e388fa89e635436a (patch)
tree596851ba8fbaba03f509247abfa12fa49fbd5057 /drivers/usb/musb
parent1e6eebb4e907548d53347a6e90769feb3d73e9da (diff)
usb: musb: ux500: harden checks for platform data
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: linux-usb@vger.kernel.org Acked-by: Felipe Balbi <balbi@ti.com> Acked-by: Fabio Baltieri <fabio.baltieri@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/usb/musb')
-rw-r--r--drivers/usb/musb/ux500_dma.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/usb/musb/ux500_dma.c b/drivers/usb/musb/ux500_dma.c
index 382291b91f7b..4bd5400e0395 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)
289 struct musb *musb = controller->private_data; 289 struct musb *musb = controller->private_data;
290 struct device *dev = musb->controller; 290 struct device *dev = musb->controller;
291 struct musb_hdrc_platform_data *plat = dev->platform_data; 291 struct musb_hdrc_platform_data *plat = dev->platform_data;
292 struct ux500_musb_board_data *data = plat->board_data; 292 struct ux500_musb_board_data *data;
293 struct dma_channel *dma_channel = NULL; 293 struct dma_channel *dma_channel = NULL;
294 u32 ch_num; 294 u32 ch_num;
295 u8 dir; 295 u8 dir;
@@ -299,14 +299,19 @@ static int ux500_dma_controller_start(struct dma_controller *c)
299 struct ux500_dma_channel *channel_array; 299 struct ux500_dma_channel *channel_array;
300 dma_cap_mask_t mask; 300 dma_cap_mask_t mask;
301 301
302 if (!plat) {
303 dev_err(musb->controller, "No platform data\n");
304 return -EINVAL;
305 }
302 306
307 data = plat->board_data;
303 308
304 dma_cap_zero(mask); 309 dma_cap_zero(mask);
305 dma_cap_set(DMA_SLAVE, mask); 310 dma_cap_set(DMA_SLAVE, mask);
306 311
307 /* Prepare the loop for RX channels */ 312 /* Prepare the loop for RX channels */
308 channel_array = controller->rx_channel; 313 channel_array = controller->rx_channel;
309 param_array = data->dma_rx_param_array; 314 param_array = data ? data->dma_rx_param_array : NULL;
310 315
311 for (dir = 0; dir < 2; dir++) { 316 for (dir = 0; dir < 2; dir++) {
312 for (ch_num = 0; 317 for (ch_num = 0;
@@ -339,7 +344,7 @@ static int ux500_dma_controller_start(struct dma_controller *c)
339 344
340 /* Prepare the loop for TX channels */ 345 /* Prepare the loop for TX channels */
341 channel_array = controller->tx_channel; 346 channel_array = controller->tx_channel;
342 param_array = data->dma_tx_param_array; 347 param_array = data ? data->dma_tx_param_array : NULL;
343 is_tx = 1; 348 is_tx = 1;
344 } 349 }
345 350