]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
misc: fastrpc: Fix initial memory allocation for Audio PD memory pool
authorEkansh Gupta <ekansh.gupta@oss.qualcomm.com>
Fri, 24 Jul 2026 22:33:37 +0000 (23:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 Jul 2026 08:59:47 +0000 (10:59 +0200)
The initial buffer allocated for the Audio PD memory pool is never added
to the pool because pageslen is set to 0. As a result, the buffer is not
registered with Audio PD and is never used, causing a memory leak. Audio
PD immediately falls back to allocating memory from the remote heap since
the pool starts out empty.

Fix this by setting pageslen to 1 so that the initially allocated buffer
is correctly registered and becomes part of the Audio PD memory pool.

Fixes: 0871561055e66 ("misc: fastrpc: Add support for audiopd")
Cc: stable@kernel.org
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Ekansh Gupta <ekansh.gupta@oss.qualcomm.com>
Signed-off-by: Jianping Li <jianping.li@oss.qualcomm.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260724223342.629168-2-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/fastrpc.c

index f3a49384586d1f07c6298811971ba811e9779c29..4f01ebfa6f95e47e6d3b65a61b55bc74e52dcd0c 100644 (file)
@@ -1370,7 +1370,9 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
                err = PTR_ERR(name);
                goto err;
        }
-
+       inbuf.client_id = fl->client_id;
+       inbuf.namelen = init.namelen;
+       inbuf.pageslen = 0;
        if (!fl->cctx->remote_heap) {
                err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen,
                                                &fl->cctx->remote_heap);
@@ -1393,12 +1395,10 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl,
                                goto err_map;
                        }
                        scm_done = true;
+                       inbuf.pageslen = 1;
                }
        }
 
-       inbuf.client_id = fl->client_id;
-       inbuf.namelen = init.namelen;
-       inbuf.pageslen = 0;
        fl->pd = USER_PD;
 
        args[0].ptr = (u64)(uintptr_t)&inbuf;