Skip to content

Commit ae85dab

Browse files
Dan Carpenterstorulf
authored andcommitted
firmware: thead,th1520-aon: Fix use after free in th1520_aon_init()
Record the error code before freeing "aon_chan" to avoid a use after free. Fixes: e4b3cbd ("firmware: thead: Add AON firmware protocol driver") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/r/f19be994-d355-48a6-ab45-d0f7e5955daf@stanley.mountain Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 6cf5db7 commit ae85dab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/firmware/thead,th1520-aon.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ struct th1520_aon_chan *th1520_aon_init(struct device *dev)
203203
{
204204
struct th1520_aon_chan *aon_chan;
205205
struct mbox_client *cl;
206+
int ret;
206207

207208
aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL);
208209
if (!aon_chan)
@@ -217,8 +218,9 @@ struct th1520_aon_chan *th1520_aon_init(struct device *dev)
217218
aon_chan->ch = mbox_request_channel_byname(cl, "aon");
218219
if (IS_ERR(aon_chan->ch)) {
219220
dev_err(dev, "Failed to request aon mbox chan\n");
221+
ret = PTR_ERR(aon_chan->ch);
220222
kfree(aon_chan);
221-
return ERR_CAST(aon_chan->ch);
223+
return ERR_PTR(ret);
222224
}
223225

224226
mutex_init(&aon_chan->transaction_lock);

0 commit comments

Comments
 (0)