summaryrefslogtreecommitdiff
path: root/arch/arm
diff options
context:
space:
mode:
authorLi Jun <B47624@freescale.com>2014-03-20 15:07:16 +0800
committerNitin Garg <nitin.garg@freescale.com>2014-06-03 23:02:12 -0500
commit3a9f69c77b7ed274de10b41f09eafcddbbbb6d0a (patch)
treeedc9f0082c06abb82e56befe0b5d6ccd9698eeec /arch/arm
parent4ae33ad2fef1378d9adfef286b8ba42fbd71cdde (diff)
ENGR00304407 arm: plat-mxc: Correct error handling routine of adding usb platform devices
Fix defects in udc and otg platform devices init: - Dereference pointer pdev after finding it's NULL. - Wrong jump when error handling when kmalloc for pdev->dev.dma_mask fails. - Remove unnecessary NULL point check. Signed-off-by: Li Jun <b47624@freescale.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/plat-mxc/devices/platform-fsl-usb2-otg.c15
-rw-r--r--arch/arm/plat-mxc/devices/platform-fsl-usb2-udc.c15
2 files changed, 14 insertions, 16 deletions
diff --git a/arch/arm/plat-mxc/devices/platform-fsl-usb2-otg.c b/arch/arm/plat-mxc/devices/platform-fsl-usb2-otg.c
index da7b22140293..47893c012901 100644
--- a/arch/arm/plat-mxc/devices/platform-fsl-usb2-otg.c
+++ b/arch/arm/plat-mxc/devices/platform-fsl-usb2-otg.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2014 Freescale Semiconductor, Inc. All Rights Reserved.
*
* Based on Uwe Kleine-Koenig's platform-fsl-usb2-udc.c
* Copyright (C) 2010 Pengutronix
@@ -50,7 +50,7 @@ struct platform_device *__init imx_add_fsl_usb2_otg(
pdev = platform_device_alloc(name, id);
if (!pdev)
- goto err;
+ return ERR_PTR(ret);
if (dmamask) {
/*
@@ -63,7 +63,7 @@ struct platform_device *__init imx_add_fsl_usb2_otg(
kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
if (!pdev->dev.dma_mask)
/* ret is still -ENOMEM; */
- goto err;
+ goto err1;
*pdev->dev.dma_mask = dmamask;
pdev->dev.coherent_dma_mask = dmamask;
@@ -73,16 +73,15 @@ struct platform_device *__init imx_add_fsl_usb2_otg(
if (ret)
goto err;
- if (data) {
- ret = platform_device_add_data(pdev, pdata, size_data);
- if (ret)
- goto err;
- }
+ ret = platform_device_add_data(pdev, pdata, size_data);
+ if (ret)
+ goto err;
return pdev;
err:
if (dmamask)
kfree(pdev->dev.dma_mask);
+err1:
platform_device_put(pdev);
return ERR_PTR(ret);
}
diff --git a/arch/arm/plat-mxc/devices/platform-fsl-usb2-udc.c b/arch/arm/plat-mxc/devices/platform-fsl-usb2-udc.c
index 4c54e1109f9d..3c53f598ce67 100644
--- a/arch/arm/plat-mxc/devices/platform-fsl-usb2-udc.c
+++ b/arch/arm/plat-mxc/devices/platform-fsl-usb2-udc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2011-2014 Freescale Semiconductor, Inc. All Rights Reserved.
*
* Copyright (C) 2010 Pengutronix
* Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
@@ -69,7 +69,7 @@ struct platform_device *__init imx_add_fsl_usb2_udc(
pdev = platform_device_alloc(name, id);
if (!pdev)
- goto err;
+ return ERR_PTR(ret);
if (dmamask) {
/*
@@ -82,7 +82,7 @@ struct platform_device *__init imx_add_fsl_usb2_udc(
kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL);
if (!pdev->dev.dma_mask)
/* ret is still -ENOMEM; */
- goto err;
+ goto err1;
*pdev->dev.dma_mask = dmamask;
pdev->dev.coherent_dma_mask = dmamask;
@@ -92,17 +92,16 @@ struct platform_device *__init imx_add_fsl_usb2_udc(
if (ret)
goto err;
- if (data) {
- ret = platform_device_add_data(pdev, pdata, size_data);
- if (ret)
- goto err;
- }
+ ret = platform_device_add_data(pdev, pdata, size_data);
+ if (ret)
+ goto err;
return pdev;
err:
if (dmamask)
kfree(pdev->dev.dma_mask);
+err1:
platform_device_put(pdev);
return ERR_PTR(ret);
}