Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532256 > unrolled thread

[PATCH 1/1] usb: fix improper return value when kzalloc fails

Started byPan Bian <bianpan2016@163.com>
First post2016-11-29 14:00 +0100
Last post2016-11-29 14:00 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] usb: fix improper return value when kzalloc fails Pan Bian <bianpan2016@163.com> - 2016-11-29 14:00 +0100

#1532256 — [PATCH 1/1] usb: fix improper return value when kzalloc fails

FromPan Bian <bianpan2016@163.com>
Date2016-11-29 14:00 +0100
Subject[PATCH 1/1] usb: fix improper return value when kzalloc fails
Message-ID<sIQaS-9a-15@gated-at.bofh.it>
The comment says function wa_nep_queue() should return 0 if ok, and <0
errno code on error. However, its implementation always returns 0, even
if the call to kzalloc() fails. As a result, the return value may be
inconsistent with the execution status, which may mislead the callers.
This patch fixes the bug, returning -ENOMEM when the call to kzalloc()
fails.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/usb/wusbcore/wa-nep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/wusbcore/wa-nep.c b/drivers/usb/wusbcore/wa-nep.c
index ed46222..e3819fc 100644
--- a/drivers/usb/wusbcore/wa-nep.c
+++ b/drivers/usb/wusbcore/wa-nep.c
@@ -198,6 +198,7 @@ static int wa_nep_queue(struct wahc *wa, size_t size)
 	if (nw == NULL) {
 		if (printk_ratelimit())
 			dev_err(dev, "No memory to queue notification\n");
+		result = -ENOMEM;
 		goto out;
 	}
 	INIT_WORK(&nw->work, wa_notif_dispatch);
-- 
1.9.1

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web