From patchwork Fri Oct 11 10:40:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Su Hui X-Patchwork-Id: 13832453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 324A1CFD35C for ; Fri, 11 Oct 2024 12:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=4Trp3WZFASkh/XSMWBtL7UGkUC6SbohSGqd4Dqcj690=; b=pJMTjDjxLhiwV3iFpEK/Gy7+mB RXaM8c4/nEBj1JU7qELcAXknlDsEyVtkVDpGEisQLhQNmT9Xnh8vx5ul7zrO42psz8b+tbubv7KZl 21yxpKJiXNxNRQ+If06syvZi7JdwsepcjCYCYT/C2iPc610yiKvYvFLtBw+WbC1c3ds36CTqif2Vr 7deZlPDLbO77UE1/EzAgvC9SgWsDorqgDgaskauneFXq2vaypt0mnPZ5Lb6qgLB/WKJ+vYH339X+/ 3jRkPIJgUPoGe+BrNDu5sf03YHdSSwsQcbWmdPk5llIMUTP/m5SYV49NCO8hgZG4O0tMehSl5wM75 +GgBlyIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1szEKt-0000000GChn-2xLW; Fri, 11 Oct 2024 12:01:35 +0000 Received: from [42.101.60.213] (helo=mail.nfschina.com) by bombadil.infradead.org with smtp (Exim 4.98 #2 (Red Hat Linux)) id 1szD98-0000000G2mN-1u8l for linux-arm-kernel@lists.infradead.org; Fri, 11 Oct 2024 10:45:24 +0000 Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (MailData Gateway V2.8.8) with ESMTPSA id 24E1660858D49; Fri, 11 Oct 2024 18:40:26 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: sudeep.holla@arm.com, cristian.marussi@arm.com, nathan@kernel.org, ndesaulniers@google.com, morbo@google.com, justinstitt@google.com Cc: Su Hui , arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org Subject: [PATCH] firmware: arm_scmi: fix the double free in scmi_debugfs_common_setup() Date: Fri, 11 Oct 2024 18:40:02 +0800 Message-Id: <20241011104001.1546476-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241011_034522_667970_CDDA41E8 X-CRM114-Status: UNSURE ( 7.49 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Clang static checker(scan-build) warning: drivers/firmware/arm_scmi/driver.c:line 2915, column 2 Attempt to free released memory. When devm_add_action_or_reset() failed , scmi_debugfs_common_cleanup() will run twice which caused double free of 'dbg->name'. Remove the redundant scmi_debugfs_common_cleanup() to fix this problem. Fixes: c3d4aed763ce ("firmware: arm_scmi: Populate a common SCMI debugfs root") Signed-off-by: Su Hui Reviewed-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 88c5c4ff4bb6..a477b5ade38d 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2976,10 +2976,8 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info) dbg->top_dentry = top_dentry; if (devm_add_action_or_reset(info->dev, - scmi_debugfs_common_cleanup, dbg)) { - scmi_debugfs_common_cleanup(dbg); + scmi_debugfs_common_cleanup, dbg)) return NULL; - } return dbg; }