staging: vchiq: Fix refcounting bug in buffer_from_host()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 22 Jul 2020 13:06:51 +0000 (16:06 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Jul 2020 08:05:33 +0000 (10:05 +0200)
If we fail to queue the buffer then it can never be dequeued.  This can
lead to a forever loop in stop_streaming() when we wait for everything
to finish.

Fixes: 70ec64ccdaac ("staging: bcm2835-camera: Ensure all buffers are returned on disable")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200722130651.GC220681@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c

index 744ceb5..e798d49 100644 (file)
@@ -441,6 +441,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance,
        ret = vchiq_queue_kernel_message(instance->service_handle, &m,
                                         sizeof(struct mmal_msg_header) +
                                         sizeof(m.u.buffer_from_host));
+       if (ret)
+               atomic_dec(&port->buffers_with_vpu);
 
        vchiq_release_service(instance->service_handle);