Re: [PATCH linux-next v2 1/3] platform/x86/intel/tpmi: Fix double free in tpmi_create_device()

From: Dan Carpenter
Date: Tue Mar 14 2023 - 10:23:11 EST


On Thu, Mar 09, 2023 at 12:01:05PM +0800, Dongliang Mu wrote:
> 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@xxxxxxxxxxx>
> ---

Yeah. These patches are right. The earlier fix still has a double
free. Devres stuff is confusing...

Reviewed-by: Dan Carpenter <error27@xxxxxxxxx>

regards,
dan carpenter