remoteproc: core: Fix rproc->firmware free in rproc_set_firmware()
PATCH 1/1 remoteproc: core: Fix rproc->firmware free in rproc_set_firmware()
From: Daniele Alessandrelli <[email protected]>
rproc_alloc_firmware() (called by rproc_alloc()) can allocate rproc->firmware using kstrdup_const() and therefore should be freed using kfree_const(); however, rproc_set_firmware() frees it using the simple kfree(). This causes a kernel oops if a constant string is passed to rproc_alloc() and rproc_set_firmware() is subsequently called.
Fix the above issue by using kfree_const() to free rproc->firmware in rproc_set_firmware().
--- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
@@ -1988,7 +1988,7 @@ int rproc_set_firmware(struct rproc *rproc, const char *fw_name) goto out; } -kfree (rproc->firmware); +kfree_const (rproc->firmware); rproc->firmware = p; out:
base-commit: 8cc8eeffd058f3e7e2d8710a514ffcbc2bd69d28
Signature · 1 line
2.26.2
Mathieu Poirier
maintainerGood morning,
Quoted 21 lines · Daniele Alessandrelli
From: Daniele Alessandrelli <[email protected]>
rproc_alloc_firmware()(called byrproc_alloc()) can allocaterproc->firmwareusingkstrdup_const()and therefore should be freed usingkfree_const(); however,rproc_set_firmware()frees it using the simplekfree(). This causes a kernel oops if a constant string is passed torproc_alloc()andrproc_set_firmware()is subsequently called.Fix the above issue by using
kfree_const()to freerproc->firmwareinrproc_set_firmware().Signed-off-by Daniele Alessandrelli <[email protected]>--- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/remoteproc_core.c +0
-0
drivers/remoteproc/remoteproc_core.c int rproc_set_firmware(struct rproc *rproc, const char *fw_name) · line 1992
Quoted 6 lines
drivers/remoteproc/remoteproc_core.c +1
-1@@ -1988,7 +1988,7 @@ int rproc_set_firmware(struct rproc *rproc, const char *fw_name) goto out; } -kfree (rproc->firmware); +kfree_const (rproc->firmware); rproc->firmware = p;
Thanks for the fix, I will pick it up shortly.
Mathieu
Quoted 7 lines
drivers/remoteproc/remoteproc_core.c +0
-0out:base-commit:
8cc8eeffd058f3e7e2d8710a514ffcbc2bd69d28Signature · 1 line
2.26.2
Quoted 21 lines · Daniele Alessandrelli
From: Daniele Alessandrelli <[email protected]>
rproc_alloc_firmware()(called byrproc_alloc()) can allocaterproc->firmwareusingkstrdup_const()and therefore should be freed usingkfree_const(); however,rproc_set_firmware()frees it using the simplekfree(). This causes a kernel oops if a constant string is passed torproc_alloc()andrproc_set_firmware()is subsequently called.Fix the above issue by using
kfree_const()to freerproc->firmwareinrproc_set_firmware().Signed-off-by Daniele Alessandrelli <[email protected]>--- drivers/remoteproc/remoteproc_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/remoteproc/remoteproc_core.c +0
-0
drivers/remoteproc/remoteproc_core.c int rproc_set_firmware(struct rproc *rproc, const char *fw_name) · line 1992
Quoted 6 lines
drivers/remoteproc/remoteproc_core.c +1
-1@@ -1988,7 +1988,7 @@ int rproc_set_firmware(struct rproc *rproc, const char *fw_name) goto out; } -kfree (rproc->firmware); +kfree_const (rproc->firmware); rproc->firmware = p;
Quoted 7 lines
drivers/remoteproc/remoteproc_core.c +0
-0out:base-commit:
8cc8eeffd058f3e7e2d8710a514ffcbc2bd69d28Signature · 1 line
2.26.2
This patch was applied to andersson/remoteproc.git (refs/heads/for-next):
Hello:
This patch was applied to andersson/remoteproc.git (refs/heads/for-next):
Quoted 9 lines · On Mon, 18 Jan 2021 16:59:04 +0000 you wrote:
From: Daniele Alessandrelli <[email protected]>
rproc_alloc_firmware()(called byrproc_alloc()) can allocaterproc->firmwareusingkstrdup_const()and therefore should be freed usingkfree_const(); however,rproc_set_firmware()frees it using the simplekfree(). This causes a kernel oops if a constant string is passed torproc_alloc()andrproc_set_firmware()is subsequently called.[...]
Here is the summary with links:
- remoteproc: core: Fix rproc->firmware free in rproc_set_firmware()
https://git.kernel.org/andersson/remoteproc/c/43d3f2c715ce
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html