Commit ae85dabc authored by Dan Carpenter's avatar Dan Carpenter Committed by Ulf Hansson
Browse files

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: e4b3cbd8 ("firmware: thead: Add AON firmware protocol driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/f19be994-d355-48a6-ab45-d0f7e5955daf@stanley.mountain


Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 6cf5db71
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -203,6 +203,7 @@ struct th1520_aon_chan *th1520_aon_init(struct device *dev)
{
	struct th1520_aon_chan *aon_chan;
	struct mbox_client *cl;
	int ret;

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

	mutex_init(&aon_chan->transaction_lock);