]> git.itanic.dy.fi Git - linux-stable/commit
firmware: arm_scmi: Avoid double free in error flow
authorWen Yang <wenyang@linux.alibaba.com>
Mon, 25 Nov 2019 15:54:09 +0000 (23:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Dec 2019 19:35:52 +0000 (20:35 +0100)
commit372098d54b33a0431d35be06074efae0a35ce744
tree03e88da9cc76545c4ffaaefee9dbd493bdee34ff
parentf7654ebe928d46bd540e0305dbdcc57752de424c
firmware: arm_scmi: Avoid double free in error flow

[ Upstream commit 8305e90a894f82c278c17e51a28459deee78b263 ]

If device_register() fails, both put_device() and kfree() are called,
ending with a double free of the scmi_dev.

Calling kfree() is needed only when a failure happens between the
allocation of the scmi_dev and its registration, so move it to there
and remove it from the error flow.

Fixes: 46edb8d1322c ("firmware: arm_scmi: provide the mandatory device release callback")
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/firmware/arm_scmi/bus.c