diff options
author | Álvaro Fernández Rojas <noltari@gmail.com> | 2021-02-18 18:04:33 +0100 |
---|---|---|
committer | Álvaro Fernández Rojas <noltari@gmail.com> | 2021-02-18 23:42:32 +0100 |
commit | f07e572f6447465d8938679533d604e402b0f066 (patch) | |
tree | cb333bd2a67e59e7c07659514850a0fd55fc825e /target/linux/bcm27xx/patches-5.4/950-1019-staging-vcsm-cma-Fix-memory-leak-from-not-detaching-.patch | |
parent | 5d3a6fd970619dfc55f8259035c3027d7613a2a6 (diff) | |
download | upstream-f07e572f6447465d8938679533d604e402b0f066.tar.gz upstream-f07e572f6447465d8938679533d604e402b0f066.tar.bz2 upstream-f07e572f6447465d8938679533d604e402b0f066.zip |
bcm27xx: import latest patches from the RPi foundation
bcm2708: boot tested on RPi B+ v1.2
bcm2709: boot tested on RPi 3B v1.2 and RPi 4B v1.1 4G
bcm2710: boot tested on RPi 3B v1.2
bcm2711: boot tested on RPi 4B v1.1 4G
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Diffstat (limited to 'target/linux/bcm27xx/patches-5.4/950-1019-staging-vcsm-cma-Fix-memory-leak-from-not-detaching-.patch')
-rw-r--r-- | target/linux/bcm27xx/patches-5.4/950-1019-staging-vcsm-cma-Fix-memory-leak-from-not-detaching-.patch | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/target/linux/bcm27xx/patches-5.4/950-1019-staging-vcsm-cma-Fix-memory-leak-from-not-detaching-.patch b/target/linux/bcm27xx/patches-5.4/950-1019-staging-vcsm-cma-Fix-memory-leak-from-not-detaching-.patch new file mode 100644 index 0000000000..992adc67fb --- /dev/null +++ b/target/linux/bcm27xx/patches-5.4/950-1019-staging-vcsm-cma-Fix-memory-leak-from-not-detaching-.patch @@ -0,0 +1,77 @@ +From 6ff310748f67d98d1c2c8ea75decd9dee13aa50c Mon Sep 17 00:00:00 2001 +From: Dave Stevenson <dave.stevenson@raspberrypi.com> +Date: Wed, 4 Nov 2020 18:54:20 +0000 +Subject: [PATCH] staging: vcsm-cma: Fix memory leak from not + detaching dmabuf + +When importing there was a missing call to detach the buffer, +so each import leaked the sg table entry. + +Actually the release process for both locally allocated and +imported buffers is identical, so fix them to both use the same +function. + +Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> +--- + .../staging/vc04_services/vc-sm-cma/vc_sm.c | 22 ++----------------- + 1 file changed, 2 insertions(+), 20 deletions(-) + +--- a/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c ++++ b/drivers/staging/vc04_services/vc-sm-cma/vc_sm.c +@@ -237,6 +237,7 @@ static void vc_sm_add_resource(struct vc + + /* + * Cleans up imported dmabuf. ++ * Should be called with mutex held. + */ + static void vc_sm_clean_up_dmabuf(struct vc_sm_buffer *buffer) + { +@@ -244,7 +245,6 @@ static void vc_sm_clean_up_dmabuf(struct + return; + + /* Handle cleaning up imported dmabufs */ +- mutex_lock(&buffer->lock); + if (buffer->import.sgt) { + dma_buf_unmap_attachment(buffer->import.attach, + buffer->import.sgt, +@@ -255,7 +255,6 @@ static void vc_sm_clean_up_dmabuf(struct + dma_buf_detach(buffer->dma_buf, buffer->import.attach); + buffer->import.attach = NULL; + } +- mutex_unlock(&buffer->lock); + } + + /* +@@ -687,23 +686,6 @@ int vc_sm_import_dmabuf_mmap(struct dma_ + } + + static +-void vc_sm_import_dma_buf_release(struct dma_buf *dmabuf) +-{ +- struct vc_sm_buffer *buf = dmabuf->priv; +- +- pr_debug("%s: Relasing dma_buf %p\n", __func__, dmabuf); +- mutex_lock(&buf->lock); +- if (!buf->imported) +- return; +- +- buf->in_use = 0; +- +- vc_sm_vpu_free(buf); +- +- vc_sm_release_resource(buf); +-} +- +-static + void *vc_sm_import_dma_buf_kmap(struct dma_buf *dmabuf, + unsigned long offset) + { +@@ -753,7 +735,7 @@ static const struct dma_buf_ops dma_buf_ + .map_dma_buf = vc_sm_import_map_dma_buf, + .unmap_dma_buf = vc_sm_import_unmap_dma_buf, + .mmap = vc_sm_import_dmabuf_mmap, +- .release = vc_sm_import_dma_buf_release, ++ .release = vc_sm_dma_buf_release, + .attach = vc_sm_import_dma_buf_attach, + .detach = vc_sm_import_dma_buf_detatch, + .begin_cpu_access = vc_sm_import_dma_buf_begin_cpu_access, |