aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0326-staging-bcm2835-codec-Fix-imbalance-in-dma_buf_get-d.patch
blob: f0fdfd29c8333594593868ef0d7adebf6b97a5f7 (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 0c941589b9bfb07cd31c792b445e630817e956d1 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;