Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: fix improper return value when kzalloc fails

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Pan Bian and committed by
Greg Kroah-Hartman
7faf44bf cd63a1c1

+1
+1
drivers/usb/wusbcore/wa-nep.c
··· 198 198 if (nw == NULL) { 199 199 if (printk_ratelimit()) 200 200 dev_err(dev, "No memory to queue notification\n"); 201 + result = -ENOMEM; 201 202 goto out; 202 203 } 203 204 INIT_WORK(&nw->work, wa_notif_dispatch);