Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17924420ybl; Thu, 2 Jan 2020 14:55:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyLPrzMR4tNmOC0nX9AYDzVcW27Of8JIjffjb9eafY7g5RMu8e7FIjwvm0zLzDinWyogQFY X-Received: by 2002:a05:6830:2102:: with SMTP id i2mr92395431otc.123.1578005732179; Thu, 02 Jan 2020 14:55:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005732; cv=none; d=google.com; s=arc-20160816; b=uod0nbINozBS69g71c0iQQCkQHyc1dWMkWMt3nkJfzLYoOSzTXZVCFLzDqQaxPn4BO v/pTBuRV+SeNOmc3ozn3gqWpMHUJY4JUcv2zkACSFKMLVOTRsA2cC4WVhY6KY+pbAIkD xnLeGDifNnIX5nCcrFVLECzy3NtFXABLV3bf/oy/TB9z0bDtjUxPI4CNTLKcRWZiEswD sh5NGxXeAbr/HZptCnSl8fW8AcrMKqHMPKIxcEXtrV/By9KbmZW44or7aEKgJVLnVdpC daI369m5BsjlAWmnlc2ydXYolsmbo9LBXPuCKPnKsE3G51yEAxIMrXj/cHdxAxqcA7XC b4cA== 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=FsMpOn+tjGIBEcyWrcts8BcN5E9YrgGKp5B9YRXyem8=; b=0BoS8bZLnXVAPkLZ7nw5ofTmpXBKHr/pLIdI6OvlCsaUzcUQOUzS6kfsqBeOukuURA wXhDkP/Tb4GPT7IYeC+/Vz9yoX2fX2J2aHdVKxMQTI7Lok0kpCg4lJ/0I0zUqHC/vdYF 3VDSd40HSTUmSGGzV0cnowv1Jf+kw9H9kEgNXZ3QHzz5+tFcqyhcbFk/AuRS+s6m96gr R7PRhE/R6WbhVQwLgJCVld9FWpL7l37Z9xZGWXZGsHyaK5fHPbsfS0tqXDhb32bJ5F6U /T5/1EDPSVlE1wF5r7oeatLB+KFXz/sw4NzZ/z7hDcaX2HUH0MXzXHIDSGSyXTbbZ/lP A68g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TcC2GfEt; 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 z11si22047504oic.176.2020.01.02.14.55.20; Thu, 02 Jan 2020 14:55:32 -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=TcC2GfEt; 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 S1728917AbgABWVA (ORCPT + 99 others); Thu, 2 Jan 2020 17:21:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:39278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727657AbgABWU4 (ORCPT ); Thu, 2 Jan 2020 17:20:56 -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 CA46821582; Thu, 2 Jan 2020 22:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003656; bh=l0lnWMKFbSvkJ0RjmrMFRUbEtOFifJZOAfuYohiIE8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TcC2GfEtHCFzsVqrGfVHXlASJ8XrodkjkGTwLvrTjxjTL9CTx4sac1YdNULce1sF3 YsWMZV4+yKuTYp2eIG1PoSWqlX5ZHNmpRg0s0r6dawRwkoBPWp+znexSgu3PpqoNI9 7SJQsSYYp3UY51SkLAgnzWRhfQ/8z25X42473RxQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masahiro Yamada , Sasha Levin Subject: [PATCH 4.19 060/114] scripts/kallsyms: fix definitely-lost memory leak Date: Thu, 2 Jan 2020 23:07:12 +0100 Message-Id: <20200102220035.073333687@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@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 31ed7f3f0e15..4b2711c23f4e 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -491,6 +491,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