greybus: operation: fix null-deref on operation destroy
authorJohan Hovold <johan@hovoldconsulting.com>
Fri, 27 Mar 2015 11:41:17 +0000 (12:41 +0100)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 30 Mar 2015 13:13:01 +0000 (15:13 +0200)
Incoming operations are created without a response message. If a
protocol driver fails to send a response, or if the operation were to be
cancelled before it has been fully processed, we get a null-pointer
dereference when the operation is released.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/operation.c

index 17f4eab..cb0c87a 100644 (file)
@@ -607,7 +607,8 @@ static void _gb_operation_destroy(struct kref *kref)
        list_del(&operation->links);
        spin_unlock_irqrestore(&gb_operations_lock, flags);
 
-       gb_operation_message_free(operation->response);
+       if (operation->response)
+               gb_operation_message_free(operation->response);
        gb_operation_message_free(operation->request);
 
        kmem_cache_free(gb_operation_cache, operation);