Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1354543pxv; Fri, 2 Jul 2021 01:29:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpFYsiRTqSjIRquUDI10B8i/zaUicxSO1ik1CVX1y1vGmFdNNHZASnCrh7/5XD+eDRfamS X-Received: by 2002:a05:6e02:1d10:: with SMTP id i16mr260694ila.5.1625214561278; Fri, 02 Jul 2021 01:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625214561; cv=none; d=google.com; s=arc-20160816; b=xVu+CYWMhEzEq7Hn2x4+V/Av+6OYwEmzZiqNuC9HEG1xn+pj0bOAuYtJyTVpG+Awnz hCsps56cTChIT10mgVbWfUnLZzjFArImetGxBU/0c7+6IezELF6ZxP+eFXbpDzz+Syi5 dSt+yn5tRiCmJvwT1vH0jHHkJE0ne8i8mTICqMwprYBNyV4FXgbdIg/pfXpSx2dBa5Hn fM7ZBsUvcs//L5BxDXbhyHdecbntb1u+FqBl3bVGkCCd4lVAazaNQ1fh7BTkHU4wjNBd 5bmJvrE5p+lt4ZMsldO0wm5LT0EuKuVHNusSZRfiKy0TYbEaO6hN4l24dPCAT1qVbhns 9NdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature:dkim-signature; bh=WxJWw2CqLjQ4AZ75S144xJsmeSvAip+8rmh0FMz/5GM=; b=ESR2JFbZNKyVDnekmoN2C1UVPno3GoGpZj8Rz3lnvOGsII1+W7Y6n9XB1Zhkg+qEoB Lvg2WpBo2CXIkmnT1pF7pzidIIigNtkodpjH9GzCnWksdWFc4pS/a1+b8MeCt2Wny6+s YYXc8hcJjvSMB/J+AD/X09S/ZPPs+ibMQXjT8fZOKtfvyvLMeTqX8Sm7q0FuayXI+qgY pFpKySlsqVDeIl9Exu2e29LqLV0DOm1aKlfUdZ8SSM64xzFBbACQkZ87Q6S8vGsljqpa A37nkJybZgKUjFYhoBht9YkcF360vnC1sVM8D7xXM9FjahUi9HjsjRIx5JtvAEUoL+HT YAEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lkUj24Ii; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e16si2926812iom.90.2021.07.02.01.29.09; Fri, 02 Jul 2021 01:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lkUj24Ii; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbhGBI3D (ORCPT + 99 others); Fri, 2 Jul 2021 04:29:03 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:54978 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230023AbhGBI3C (ORCPT ); Fri, 2 Jul 2021 04:29:02 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1376C22961; Fri, 2 Jul 2021 08:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1625214389; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WxJWw2CqLjQ4AZ75S144xJsmeSvAip+8rmh0FMz/5GM=; b=lkUj24IiRvJIFfbBu/iB88l1qdMcO1clseyNEaQKefJCuMgGcAjgdMJRWlP12kgCV9/Yhi tKyRbORZtjInluugNAS1LcxunK4xUoJoywGyxahtGQ5N81ENdJld/x7bfoqUeoLYg9WEAU jPJD63Wi4XgVJsa218wDWmyvbHlfMkI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1625214389; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WxJWw2CqLjQ4AZ75S144xJsmeSvAip+8rmh0FMz/5GM=; b=x8IuBnkDowOrrc2WoDMs/m5k/YVR3o2og0kw/SEkXusC5ZIvp3lzIuKm1dvNCeUv9UsIFd HQsALjOFSp+2BsBA== Received: from pobox.suse.cz (pobox.suse.cz [10.100.2.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id AAC2BA3B81; Fri, 2 Jul 2021 08:26:28 +0000 (UTC) Date: Fri, 2 Jul 2021 10:26:28 +0200 (CEST) From: Miroslav Benes To: gushengxian cc: jpoimboe@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, gushengxian Subject: Re: [PATCH] objtool: avoid Memory leak: orig_alt_group In-Reply-To: <20210702031327.559429-1-gushengxian507419@gmail.com> Message-ID: References: <20210702031327.559429-1-gushengxian507419@gmail.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, 1 Jul 2021, gushengxian wrote: > From: gushengxian > > free(orig_alt_group) should be added in order to avoid memery leak. > Reported by cppcheck. > > Signed-off-by: gushengxian It is not necessary. Objtool would exit immediately in case of this error and we do not handle the allocations in such cases. > --- > tools/objtool/check.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/tools/objtool/check.c b/tools/objtool/check.c > index e5947fbb9e7a..deb48b1bc16d 100644 > --- a/tools/objtool/check.c > +++ b/tools/objtool/check.c > @@ -1097,6 +1097,7 @@ static int handle_group_alt(struct objtool_file *file, > sizeof(struct cfi_state *)); > if (!orig_alt_group->cfi) { > WARN("calloc failed"); > + free(orig_alt_group); > return -1; > } There are more sites like this in the code. For example there is one a couple of lines later in the same function. It is fine. Regards Miroslav