diff mbox

usb: gadget: xudc: fix return value check in xudc_probe()

Message ID 1429186650-20465-1-git-send-email-weiyj_lk@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

weiyj_lk@163.com April 16, 2015, 12:17 p.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

In case of error, the function devm_ioremap_resource() returns
ERR_PTR() and never returns NULL. The NULL test in the return
value check should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/usb/gadget/udc/udc-xilinx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michal Simek April 16, 2015, 12:22 p.m. UTC | #1
On 04/16/2015 02:17 PM, weiyj_lk@163.com wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function devm_ioremap_resource() returns
> ERR_PTR() and never returns NULL. The NULL test in the return
> value check should be replaced with IS_ERR().
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>  drivers/usb/gadget/udc/udc-xilinx.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
> index dd3e9fd..cfe0349 100644
> --- a/drivers/usb/gadget/udc/udc-xilinx.c
> +++ b/drivers/usb/gadget/udc/udc-xilinx.c
> @@ -2071,8 +2071,8 @@ static int xudc_probe(struct platform_device *pdev)
>  	/* Map the registers */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	udc->addr = devm_ioremap_resource(&pdev->dev, res);
> -	if (!udc->addr)
> -		return -ENOMEM;
> +	if (IS_ERR(udc->addr))
> +		return PTR_ERR(udc->addr);
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0) {
> 

Reviewed-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal
Felipe Balbi April 27, 2015, 7:46 p.m. UTC | #2
Hi,

On Thu, Apr 16, 2015 at 08:17:30PM +0800, weiyj_lk@163.com wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> In case of error, the function devm_ioremap_resource() returns
> ERR_PTR() and never returns NULL. The NULL test in the return
> value check should be replaced with IS_ERR().
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

doesn't apply to v4.1-rc1, if it's still needed, please rebase.
diff mbox

Patch

diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c
index dd3e9fd..cfe0349 100644
--- a/drivers/usb/gadget/udc/udc-xilinx.c
+++ b/drivers/usb/gadget/udc/udc-xilinx.c
@@ -2071,8 +2071,8 @@  static int xudc_probe(struct platform_device *pdev)
 	/* Map the registers */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	udc->addr = devm_ioremap_resource(&pdev->dev, res);
-	if (!udc->addr)
-		return -ENOMEM;
+	if (IS_ERR(udc->addr))
+		return PTR_ERR(udc->addr);
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {