OSDN Git Service

platform/x86/intel: tpmi: Fix double free in tpmi_create_device()
authorDongliang Mu <dzm91@hust.edu.cn>
Thu, 9 Mar 2023 04:01:05 +0000 (12:01 +0800)
committerHans de Goede <hdegoede@redhat.com>
Mon, 20 Mar 2023 12:11:55 +0000 (13:11 +0100)
commit4d5a2a7d2c97dbd658533eea5f79dab1ad5dc0ee
tree7442e6af2dc4cdf950842cfd3a0c1bd42ad4363b
parentda0ba0ccce54059d6c6b788a75099bfce95126da
platform/x86/intel: tpmi: Fix double free in tpmi_create_device()

The previous commit 6a192c0cbf38 ("platform/x86/intel/tpmi: Fix
double free reported by Smatch") incorrectly handle the deallocation of
res variable. As shown in the comment, intel_vsec_add_aux handles all
the deallocation of res and feature_vsec_dev. Therefore, kfree(res) can
still cause double free if intel_vsec_add_aux returns error.

Fix this by adjusting the error handling part in tpmi_create_device,
following the function intel_vsec_add_dev.

Fixes: 6a192c0cbf38 ("platform/x86/intel/tpmi: Fix double free reported by Smatch")
Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230309040107.534716-2-dzm91@hust.edu.cn
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel/tpmi.c