]> git.baikalelectronics.ru Git - kernel.git/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)
committerSudeep Holla <sudeep.holla@arm.com>
Tue, 26 Nov 2019 10:50:30 +0000 (10:50 +0000)
commit94a0ceb230a6a74f6065c1c1e76d27509424ca41
tree9863324162c61ee80ef4f4365b204cf0db5f5c0c
parenta2c4570b341d3f21387e20a14263672e5644033e
firmware: arm_scmi: Avoid double free in error flow

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: 98f056de9381 ("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>
drivers/firmware/arm_scmi/bus.c