aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-4.19/950-0745-staging-bcm2835-codec-Fix-imbalance-in-dma_buf_get-d.patch
blob: 20550d4cb1a9279beef4ca7293b9bb3da979ce4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From 4542b5d7b4e00b11dd37d93986b624c58b198765 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
Date: Mon, 7 Oct 2019 14:02:57 +0100
Subject: [PATCH] staging: bcm2835-codec: Fix imbalance in
 dma_buf_get/dma_buf_put

When represented with a dmabuf buffer that had previously been
imported, there was a call to dma_buf_get without a matching
dma_buf_put. This left dmabufs in limbo after all users had
supposedly released them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
---
 .../staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c | 5 +++++
 1 file changed, 5 insertions(+)

--- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
+++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
@@ -2112,6 +2112,11 @@ static int bcm2835_codec_buf_prepare(str
 			}
 
 			buf->mmal.dma_buf = dma_buf;
+		} else {
+			/* We already have a reference count on the dmabuf, so
+			 * release the one we acquired above.
+			 */
+			dma_buf_put(dma_buf);
 		}
 		ret = 0;
 		break;