libusbgx: Do not try to dereference func when it is NULL. CID#56127
authorPhilippe De Swert <philippe.deswert@jollamobile.com>
Fri, 9 May 2014 12:08:41 +0000 (15:08 +0300)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 22 Dec 2015 19:39:15 +0000 (20:39 +0100)
We check if func is NULL, so if the allocation function failed we should
not dereference or handle it anymore, so we jump straight to the end.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
src/usbg.c

index 66aa435..8ad6a9e 100644 (file)
@@ -1653,6 +1653,7 @@ int usbg_create_function(usbg_gadget *g, usbg_function_type type,
        if (!func) {
                ERRORNO("allocating function\n");
                ret = USBG_ERROR_NO_MEM;
+               goto out;
        }
 
        free_space = sizeof(fpath) - n;