greybus: loopback: Retrun -ENOMEM if operation allocation fails
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Fri, 11 Dec 2015 13:46:51 +0000 (13:46 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 12 Dec 2015 00:16:01 +0000 (16:16 -0800)
If operation allocation fails we should return -ENOMEM in the asynchronous
operation send routine. If we don't return here then the
gb_loopback_async_operation_put() later can dereference a NULL pointer if
the previous gb_operation_create() failed.

Reported-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c

index 0828772..eb6a013 100644 (file)
@@ -580,8 +580,8 @@ static int gb_loopback_async_operation(struct gb_loopback *gb, int type,
        operation = gb_operation_create(gb->connection, type, request_size,
                                        response_size, GFP_KERNEL);
        if (!operation) {
-               ret = -ENOMEM;
-               goto error;
+               kfree(op_async);
+               return -ENOMEM;
        }
 
        if (request_size)