From patchwork Sat Jan 7 10:53:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 40367 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1247377wrt; Sat, 7 Jan 2023 02:56:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXukTBkPaJWcQpl9gjn+VEO3FQt2darrOUZ0oxc6UJ91jz3AW/ij7QO6ovHuSU49xK2hw1zr X-Received: by 2002:a17:902:9b90:b0:192:8cd1:5e79 with SMTP id y16-20020a1709029b9000b001928cd15e79mr39785651plp.41.1673088984808; Sat, 07 Jan 2023 02:56:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673088984; cv=none; d=google.com; s=arc-20160816; b=ofI1EC6ov6qebAZURxoSF3RqRt7foN+ZI9zJcpTXcj5HdmrLHVtVB23turPWWMLCFP koQ7PPtqwyd3TiofVwoX33YzKJo18yN8WGZHYfcAT4wK8hIc9Q6D2eqRz7Ggad+2+o4W vb/aOvhe+/AuHAyWyJvK9SUcXxJXSJMgp2mswRu4ZyY6rdYBKAVD+gvAkcS6YUqJYHHv XGO5Q6OYLlH8ocK4pC8Q8NkFUBmc/etNfPw9tVEVAr3smsmIAD/3XQhERrZ+raiMt7TR 94ByFdkGxQfW8cjLMnlcLNrVHzbH626ZTsfLMmOOdMtGs3/qWTacVG80SJcERYjIrl2h 40cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=2IG2g6yfdzj3v6AzxV31vJmclu07XKAtOZiLHWzNUv8=; b=c7fWkpusnYRcxbZeS5USiaf6wiIoOAf4fWUty8qXK0VCJeQ5yUBaM5FpGZYh6/Gsb4 U4SQTcZCfs/AsEg2yfIhEr6TDLbvddm2GosHhd6YxvUG82kSDPf4YemDCYH9PrsBhjof +Y7jz/DSPGU2yRnkkPyegyIqNrOvDoFOzbgiXliZW2NA2K3AQvjQMRWxE/00drbaFlUm QTNnHj2EEew9HfdTRFuk0ZztUuuVOemPGfDpnZULvFRPdi+3yDRoHBCAhs9kmo9jial9 2kTa1J9ZR6Qb2gn4ZIwbZ30OKespaAUhuBaT8si1PiXDM2kUuCBMLBG2z1Ly7xShLkVY 20BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uYKFVjej; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170902ea0b00b001931d382a3esi1468268plg.489.2023.01.07.02.56.12; Sat, 07 Jan 2023 02:56:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uYKFVjej; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231611AbjAGKxj (ORCPT + 99 others); Sat, 7 Jan 2023 05:53:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232161AbjAGKxP (ORCPT ); Sat, 7 Jan 2023 05:53:15 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E725A1AA35; Sat, 7 Jan 2023 02:53:13 -0800 (PST) Date: Sat, 07 Jan 2023 10:53:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673088792; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2IG2g6yfdzj3v6AzxV31vJmclu07XKAtOZiLHWzNUv8=; b=uYKFVjejgctGX8iRO6cdRK3X3cDeq1VvUhjHH+1FcARi/B+hZRgeOby4W/OkDsQP4Q2dpf XIWcKxgZRT7JqLUMJyyovetjYCQS36k1TtaHOz+NhumulSBe4AVmMBP1vuO8w0DuRoT2CM Uo1lecLjxjDvNDvQmZ3fYsupfFdbTPgQkRnilIDRD/Pv3r2yyUaeHuC6IkwgHci+oOsJ3R iQB36L+IcscXz0ZOhONZWTvULedSVZ/0SLs0CGDdP8OfkysVB9RivAJQIftgfrUgK97OK3 S+/eyip5GTPQCdslk8oErHRwWMbbDcQ1zeCZxqNoqc4WCtg5cUv4cAWSqJaiuA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673088792; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2IG2g6yfdzj3v6AzxV31vJmclu07XKAtOZiLHWzNUv8=; b=gh9PitinoVHwIX58N3Wlk/tFUxlI7cvCJ4z193dSgONJ8UbORYQQHp/q4fe8Oi7sH3O6aD qz5NUNEM1WWLYmCQ== From: "tip-bot2 for Miaoqian Lin" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Fix memory leak in create_static_call_sections() Cc: Miaoqian Lin , Ingo Molnar , Josh Poimboeuf , Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221205080642.558583-1-linmq006@gmail.com> References: <20221205080642.558583-1-linmq006@gmail.com> MIME-Version: 1.0 Message-ID: <167308879222.4906.1093835434113126695.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754360955206491910?= X-GMAIL-MSGID: =?utf-8?q?1754360955206491910?= The following commit has been merged into the objtool/core branch of tip: Commit-ID: 3da73f102309fe29150e5c35acd20dd82063ff67 Gitweb: https://git.kernel.org/tip/3da73f102309fe29150e5c35acd20dd82063ff67 Author: Miaoqian Lin AuthorDate: Mon, 05 Dec 2022 12:06:42 +04:00 Committer: Ingo Molnar CommitterDate: Sat, 07 Jan 2023 11:45:24 +01:00 objtool: Fix memory leak in create_static_call_sections() strdup() allocates memory for key_name. We need to release the memory in the following error paths. Add free() to avoid memory leak. Fixes: 1e7e47883830 ("x86/static_call: Add inline static call implementation for x86-64") Signed-off-by: Miaoqian Lin Signed-off-by: Ingo Molnar Link: https://lore.kernel.org/r/20221205080642.558583-1-linmq006@gmail.com Cc: Josh Poimboeuf Cc: Peter Zijlstra --- tools/objtool/check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index 4350be7..cab1a16 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -679,6 +679,7 @@ static int create_static_call_sections(struct objtool_file *file) if (strncmp(key_name, STATIC_CALL_TRAMP_PREFIX_STR, STATIC_CALL_TRAMP_PREFIX_LEN)) { WARN("static_call: trampoline name malformed: %s", key_name); + free(key_name); return -1; } tmp = key_name + STATIC_CALL_TRAMP_PREFIX_LEN - STATIC_CALL_KEY_PREFIX_LEN; @@ -688,6 +689,7 @@ static int create_static_call_sections(struct objtool_file *file) if (!key_sym) { if (!opts.module) { WARN("static_call: can't find static_call_key symbol: %s", tmp); + free(key_name); return -1; }