]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: return correct errno code when krealloc fails
authorPan Bian <bianpan2016@163.com>
Tue, 29 Nov 2016 12:50:30 +0000 (20:50 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Nov 2016 16:36:43 +0000 (17:36 +0100)
In function wusb_dev_sec_add(), variable result takes the return value.
Its value should be negative on failures. When function krealloc() is
called, an earlier check of variable result guarantees that the value of
result must not be less than "sizeof(*secd)", and result is not
reassigned when krealloc() returns a NULL pointer. As a result, a
positive value may be returned, which makes it impossible for the caller
of wusb_dev_sec_add() to detect the error. This patch fixes the bug by
assigning -ENOMEM to result when krealloc() returns NULL.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/wusbcore/security.c

index 8c9421b69da00adb560dc7d18719591065c0f8d8..170f2c38de9b5695e37008c9dc975787f66021cb 100644 (file)
@@ -240,6 +240,7 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
        if (new_secd == NULL) {
                dev_err(dev,
                        "Can't allocate space for security descriptors\n");
+               result = -ENOMEM;
                goto out;
        }
        secd = new_secd;