From 481d30427e5506fc1f5c27bbb94faef9d1ec72a0 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Tue, 7 May 2013 19:50:06 +0800 Subject: [PATCH] usb: gadget: dummy_hcd: fix error return code in init() Fix to return -ENOMEM in the kzalloc() error handling case instead of 0(following platform_device_add_data() will overwrite it to 0), as done elsewhere in this function. Acked-by: Alan Stern Signed-off-by: Wei Yongjun Signed-off-by: Felipe Balbi --- drivers/usb/gadget/dummy_hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 22236ecb2e29..c588e8e486e5 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c @@ -2660,8 +2660,10 @@ static int __init init(void) } for (i = 0; i < mod_data.num; i++) { dum[i] = kzalloc(sizeof(struct dummy), GFP_KERNEL); - if (!dum[i]) + if (!dum[i]) { + retval = -ENOMEM; goto err_add_pdata; + } retval = platform_device_add_data(the_hcd_pdev[i], &dum[i], sizeof(void *)); if (retval) -- 2.34.1