Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11787094pjo; Thu, 2 Jan 2020 14:16:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwFL7U7nZ9TlOa3boHvtjez6AHS4AqBLtRWYRpUNlvcKwfeki5BhIcMmLgXM5bgKFp1K8KF X-Received: by 2002:a05:6830:9a:: with SMTP id a26mr85096814oto.131.1578003388822; Thu, 02 Jan 2020 14:16:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578003388; cv=none; d=google.com; s=arc-20160816; b=c04qw4PDq45ouTm5gmStr+v+s6uT1ws5z2E2HNRIMxD2CsLnEJo24G1jjlmbWW16RW D0MXnOanlwyp1XVLTOQ7FLejt+Pyx3Ji8exWqAd/zH5qmRRbpNu/kt4oL9E75rUDT2Ra s9IlaHQkR3WZH3HHFUylYaQm3iDFEZZMVzjy85T7XThpIhcJprRWXLF7R2YAdkh3Wwdz p4LEysYt37PMSfDk/i+ir69NyiU8ti2gh3GMq3ca0tAE0temUS181F8NPAHr+szcCOe7 tZ75y/xqVJagVbHJxsWr/Ts8r48RJU75fzVZ5qxLUxXDIpfMJyuIi/ZaCQTRk7pSMUlK WGzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e85f1oMuuFPyr418y5MhsSC6eBIGoT2retkDvofXWzg=; b=GMcGMAarlzX/LepzFDYOUyVNvjBLNyAQc2LU2LT+hhAVljvkiUOZSQDMyBPMxX2RB4 dgAWy9qj5wCE4ZniWs3jsmMOohMD0cu4Ga2SCCcRQJdWmw91y+ifxiUZXWL6HuBscH7n 8tDHPjnpTL24+pQghd7KQSvwbOY6lTFxzPKiobA1a+hOYIsCbEFiw1BY16V8kVluQgKp U3wc+ZSFwYiZs2GiDGgeRdSzD5DXo8eaK2TAGRp378vALr3BH9x7QBIuwT7kBzJEkaj+ 7RPYkRiEvHF4htn9gh1Acm74GojaqQB+j3ITOVtcibJ5pkf12behm0qKmL346sa+GulI G93w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="mGn9DkS/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q20si27934587otn.297.2020.01.02.14.16.16; Thu, 02 Jan 2020 14:16:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="mGn9DkS/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbgABWPM (ORCPT + 99 others); Thu, 2 Jan 2020 17:15:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:55846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727186AbgABWPJ (ORCPT ); Thu, 2 Jan 2020 17:15:09 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4ECA024649; Thu, 2 Jan 2020 22:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003308; bh=yxRUl5bDgmXnUkV1HL7CmWXoxyfxMH8YtZWC+Kj8990=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mGn9DkS/CEyiiJRW+2B+O86Dmf5+tPBra9b8B05Fk21wG5I6g8qUu/7gVZH+kfL8b g5xgOrHX/doO89rSpQ3eWfuxgdTMEhSAFT0Re3ZA7SkxpBWp1y/z4hRAIAiSTxqd+Z wqJYqYIbKBur0eDGNAbeg4hTQdpE+uofeVn+a8g8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Sasha Levin Subject: [PATCH 5.4 106/191] scripts/kallsyms: fix definitely-lost memory leak Date: Thu, 2 Jan 2020 23:06:28 +0100 Message-Id: <20200102215841.293332499@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masahiro Yamada [ Upstream commit 21915eca088dc271c970e8351290e83d938114ac ] build_initial_tok_table() overwrites unused sym_entry to shrink the table size. Before the entry is overwritten, table[i].sym must be freed since it is malloc'ed data. This fixes the 'definitely lost' report from valgrind. I ran valgrind against x86_64_defconfig of v5.4-rc8 kernel, and here is the summary: [Before the fix] LEAK SUMMARY: definitely lost: 53,184 bytes in 2,874 blocks [After the fix] LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks Signed-off-by: Masahiro Yamada Signed-off-by: Sasha Levin --- scripts/kallsyms.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index ae6504d07fd6..fb15f09e0e38 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -489,6 +489,8 @@ static void build_initial_tok_table(void) table[pos] = table[i]; learn_symbol(table[pos].sym, table[pos].len); pos++; + } else { + free(table[i].sym); } } table_cnt = pos; -- 2.20.1