]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
firmware: vpd: Fix section enabled flag on vpd_section_destroy
authorAnton Vasilyev <vasilyev@ispras.ru>
Tue, 24 Jul 2018 15:10:38 +0000 (18:10 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:41:27 +0000 (22:41 +0200)
commit15e5a96b1e1af3fcd7c722e2119365c9e18a79b0
tree1422b27cd960e4789681b1a0798f6db2b7435dd0
parent386b28c2de45db7b252836916779a2a0a45d3ab9
firmware: vpd: Fix section enabled flag on vpd_section_destroy

[ Upstream commit 45ca3f76de0507ecf143f770570af2942f263812 ]

static struct ro_vpd and rw_vpd are initialized by vpd_sections_init()
in vpd_probe() based on header's ro and rw sizes.
In vpd_remove() vpd_section_destroy() performs deinitialization based
on enabled flag, which is set to true by vpd_sections_init().
This leads to call of vpd_section_destroy() on already destroyed section
for probe-release-probe-release sequence if first probe performs
ro_vpd initialization and second probe does not initialize it.

The patch adds changing enabled flag on vpd_section_destroy and adds
cleanup on the error path of vpd_sections_init.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/google/vpd.c