From patchwork Sat Nov 23 16:04:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 180102 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp886042ilf; Sat, 23 Nov 2019 08:05:08 -0800 (PST) X-Google-Smtp-Source: APXvYqwBnKIt5DDvPYioNq/Qfb1sxE6cd21OZ9neYHINFwBjD5xjYh2OAG7BtU66EbEhZYPXwFik X-Received: by 2002:a17:907:20d2:: with SMTP id qq18mr27797301ejb.305.1574525107959; Sat, 23 Nov 2019 08:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574525107; cv=none; d=google.com; s=arc-20160816; b=UD+A3DhobWlHcbN7NvfrFYYzdln1ePWbacwi7L3GFIi6ao2HZbPEgryx1/8Xo1OS5A h/WYkI9ZNwteRAlwLOzl8RrvXA8cjK/asBku5UuWCtRueZhpcM6OALX77JNgtAolxL4c bwV9RUB9fjjYLH7RSLjyncEGhRsZfyvK44/bS+Sq9BVkpx0i0DAK+VeT8RqLtrO9e/rN ky0aUYdsGN2Nc9pzBdNgPjUPVnSmwARZuG3cjnyaQwdMwYb+9M/+vT0Md4dpU0eG+PZ6 rl4XGyuZh08vRfhbUjiVinqBIJhMUwlssGUCKlSJB1h/4qzjm+QRCyCiYrLGjCoLWlwc aYhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=WZZFA6dol6oYL7xPQCp9izlpiyCZuwW4132+Q9wwKac=; b=aRQYIzYyxbeJrEmlCMpJisHLX3zO5RUB2Rl9WtKsBsbTZU+th1Elq8IbusULE5KQLd anGusjYGnEYm8Dr++v+OR9lpga38sfJKRU/ZcJlrETr7X2MBdJSYn1xuYAbCQevybev/ 3FXnEIWTPzIEWCAMoS0QBFUWXRnjzqWJNmybP9rq0ZrwTklrzbAUdpyREvl9niVyYe39 LRwqX8IdPogT7m5MGW9DTrdKtjb9+emGggTzthQ0rPB6XL255aieO7by5cxRqUKQPHWq 9NygyWsaq07AHbQHqELmk0E+VH6kLAkM148FCySBtyBB5uTkoItNuYOTpEYGkdYGPLIX kOnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=gp4THjHF; 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 j1si1068885eds.39.2019.11.23.08.05.07; Sat, 23 Nov 2019 08:05:07 -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=@nifty.com header.s=dec2015msa header.b=gp4THjHF; 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 S1726922AbfKWQFC (ORCPT + 26 others); Sat, 23 Nov 2019 11:05:02 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49444 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726487AbfKWQFB (ORCPT ); Sat, 23 Nov 2019 11:05:01 -0500 Received: from grover.flets-west.jp (softbank126093102113.bbtec.net [126.93.102.113]) (authenticated) by conuserg-12.nifty.com with ESMTP id xANG4l5J019106; Sun, 24 Nov 2019 01:04:48 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xANG4l5J019106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1574525088; bh=WZZFA6dol6oYL7xPQCp9izlpiyCZuwW4132+Q9wwKac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gp4THjHFa0mPASPXe10mzi1lw1vjiNOyzebQLbBxg6WwQ0kO7VHCfoqqbGMIBZ2bu ogDa4JhABiSWOBlP+etmaJ9AohyLKDBDrRp8otdiZYPFKwWTf9mhlpg5rw5mVW3uVr Sxf/26CmgGYt9CEmrqvYZSCN2TWjMr7BzN0XF4Fvl6uEWRQeQMmVZ2fvFwWcI5o4co 8dpDv2r1GXrNk0PlCLB83+75aX+UoeVyTxcO80XO7c0ob7t2C82GQ7Pmsb/Ed29XIU jEqGT6qVp3PcbryuBq1vnV/vd/N3UoIkCd0F7037ct8HA+v6gRTMUSpErkG7pRkpLK FINV9xO1FxSUw== X-Nifty-SrcIP: [126.93.102.113] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2 02/16] scripts/kallsyms: fix definitely-lost memory leak Date: Sun, 24 Nov 2019 01:04:30 +0900 Message-Id: <20191123160444.11251-3-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191123160444.11251-1-yamada.masahiro@socionext.com> References: <20191123160444.11251-1-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v2: None scripts/kallsyms.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.17.1 diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 918c2ba071b5..79641874d860 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -487,6 +487,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;