Commit e2da025a authored by Harshit Mogalapalli's avatar Harshit Mogalapalli Committed by Jia, Yingbao
Browse files

platform/x86: ISST: fix use-after-free in tpmi_sst_dev_remove()

mainline inclusion
from mainline-v6.10
commit a4edf675ba3357f60e2ee310acc15eb9cd5a8ae0
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/IB6QD3
CVE: NA
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a4edf675ba3357f60e2ee310acc15eb9cd5a8ae0



-------------------------------------------------

Intel-SIG: commit a4edf675ba33 platform/x86: ISST: fix use-after-free in tpmi_sst_dev_remove().
Backport Intel speed select ISST driver bugfix from upstream 6.11.

In tpmi_sst_dev_remove(), tpmi_sst is dereferenced after being freed.
Fix this by reordering the kfree() post the dereference.

Fixes: 9d1d36268f3d ("platform/x86: ISST: Support partitioned systems")
Signed-off-by: default avatarHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Acked-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20240517144946.289615-1-harshit.m.mogalapalli@oracle.com


Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
[ Yingbao Jia: amend commit log ]
Signed-off-by: default avatarYingbao Jia <yingbao.jia@intel.com>
parent 90838426
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1611,8 +1611,8 @@ void tpmi_sst_dev_remove(struct auxiliary_device *auxdev)
	tpmi_sst->partition_mask_current &= ~BIT(plat_info->partition);
	/* Free the package instance when the all partitions are removed */
	if (!tpmi_sst->partition_mask_current) {
		kfree(tpmi_sst);
		isst_common.sst_inst[tpmi_sst->package_id] = NULL;
		kfree(tpmi_sst);
	}
	mutex_unlock(&isst_tpmi_dev_lock);
}