Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2198481lqo; Sun, 19 May 2024 19:20:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWTu9uQCnzXLqQeuJtut4EDzXyTQO7Xz74dH9XynJP5OmANkZmsGlmEp42UxvoDarfybCbE1hVrdADoVUUpZvKnmk+1E5Fb5YaI0ndhww== X-Google-Smtp-Source: AGHT+IFj6YP3AZwse9uUmTc7vf7iQ6iNlduyeNnYt2S9Imo08dcxN1YyVAoMfmv5mgjwZzmGrDby X-Received: by 2002:a05:6808:643:b0:3c9:6d29:8ebc with SMTP id 5614622812f47-3c9970cf86bmr34399936b6e.47.1716171641954; Sun, 19 May 2024 19:20:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716171641; cv=pass; d=google.com; s=arc-20160816; b=JsvWxbjoikHXpqkQFdysvvYfGS9+pyBFz+OLDXxlLT+uEoqixmNADQYLPfQhrfDfdD xqvXMMl7YQrp53GpbkMWgP+Fe9A01g+9wPMBBdAPDDYGC9GAGbipzmHbrpVLqbXHZXj/ 2WGNXXo7TQ9X1cii5WzmUMW8t8AXs5oh8F9jRf824rYtRAectQj99LvPNiab9AXfJgjA zNEJg1PDejui4gAVYNFpQ4bMD+Lw0Nmfd1W9iqfm+m6NVV7k2tHYAawHVcqcN16HxUl+ lWt7H08KP1iQbhUpGUwH7I6UhUgDXMcSYgTzB/13hvRjL9YZSU/weP2IH7jpNhcoCit+ jpnA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=KHoKx++OQtns9MUF/QH3n1MhhBWs3T+xtVdunAwo2os=; fh=2nThFr7aZWmtASv1TT1vQrkzZso7TpAdx6faS4re0wY=; b=0dAMWpxdNhrEDSQA2CoTfV5NXasxiJHyfcLQtzbchde8q7jP3FXiVg+IpfyRJeMZLN Cn5SBWroXAALyM9zpnreGfcXYizC7Nklq+wIEG/RAUxk9rkwqv0IN3IMbIs4Cesm1g50 bDdl0QKtQGuK3VexWyqGhMqlIkKpuq2fAzOgiCp7UM9vKkn5R4cf4LsVj8huN9+v+3nk JrDw2lLOL74tsNHijmBSdORRM6Ln3qhOzuQmag9KJJgXN5+ha7BZQ0q8nqCQipBlJq+d ne0HiJWudosha9PZWIi0lgBMSNG7qTbsGApVdsf6blNSJlaAmbCs+KJp2dsPslGF8mgf mGnQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-183352-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183352-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792d7c92ac7si194546385a.720.2024.05.19.19.20.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 May 2024 19:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-183352-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=nfschina.com); spf=pass (google.com: domain of linux-kernel+bounces-183352-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-183352-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A97CC1C21596 for ; Mon, 20 May 2024 02:20:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEACCD53E; Mon, 20 May 2024 02:19:56 +0000 (UTC) Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 4285B9474; Mon, 20 May 2024 02:19:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=42.101.60.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716171596; cv=none; b=g9vDRz96yxZau7aYMrVULWB2bRjTCk/Wf/YgDbp31OE6N/48RCx4EyB2oCRdEg+GNgWY0YCALtYYUzJy9kxFyOMSmZFcajE3+IqtczmzvE+TCOpcAoKQBNTJPZ8xjo+2Dgciotq5TriWFxftNWIiEgAZUa8RHcn/NuJiuCZ7TkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716171596; c=relaxed/simple; bh=rB7dD75CY84ry20/0r/cpYaVwib9bJIdMevmIkkR3EE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=cdnLeTaW7Pq/7u1vlzZEo3Mtk5DZJKQS1vGLyXoKuSUNF8curYB7YsfzPv5WbZ0rSHLJdlyr/w0wEvOaF/a9NJFTPdZ4nx6UemuOc3M9h2Ch16qLmeYFHsHn+na/yHMNvcI6/5UFMNvtPs7UjAlgRV3nmeE2gqZsEFWm8FHQzko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com; spf=pass smtp.mailfrom=nfschina.com; arc=none smtp.client-ip=42.101.60.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPSA id 4F0696026E8D1; Mon, 20 May 2024 10:19:44 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: srinivas.pandruvada@linux.intel.com, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com Cc: Su Hui , rui.zhang@intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org Subject: [PATCH] platform/x86: ISST: fix use after free problem in tpmi_sst_dev_remove() Date: Mon, 20 May 2024 10:19:35 +0800 Message-Id: <20240520021934.113877-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit clang static checker (scan-build) warning: drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c:1614:24: Use of memory after it is freed. Using 'tpmi_sst->package_id' after releasing 'tpmi_sst' causes this problem. Change the order of releasing 'tpmi_sst' to fix this. Fixes: 9d1d36268f3d ("platform/x86: ISST: Support partitioned systems") Signed-off-by: Su Hui --- drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c index 7bac7841ff0a..7fa360073f6e 100644 --- a/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c +++ b/drivers/platform/x86/intel/speed_select_if/isst_tpmi_core.c @@ -1610,8 +1610,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); } -- 2.30.2