Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1148174ybl; Wed, 8 Jan 2020 11:53:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwJQlR2Cv9oWKh91V8lXL3uBTZAw/XvkdlOQGgK+EcAA19KwPqREh2q9zmAwqMmOU/U5Mka X-Received: by 2002:aca:3241:: with SMTP id y62mr224761oiy.31.1578513183151; Wed, 08 Jan 2020 11:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578513183; cv=none; d=google.com; s=arc-20160816; b=aqIqhoYyCOLu52d/7TivwQ8yfHMh4JcKVyywZm55wD+Gy+FRDDH6/HMVF7o3Z4ikwK 8yPxst99hh9iy+dUz4Xvmoy01V2+FUpnZp9teB+RfLh36bdSvKcLel3zZKdYRESDrQsz 3KZ/8Vuu3QmYagcgRfFTKlcu/2GlOIjY0eMc7dhlhQ8c59QZJINp/Us21Lzvi1qc7ZKG 5jLzo4rUpxL/YSpi7Y+CRuOSWeHupeMCtuiAi8qYnXvNW3p0OuVpJKUwEClC9Ye56UMh kYkZyzxjtrAzzi516w+AwLmWXZ3dggU3OpFWEjR7T4vkBYZq/1jbj2kFwALnKccUjblT ea4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=kH42/n9K9xQF2hpwmtgWWzRTD8wmmiZ2EsgPoBiS4WQ=; b=LbGv4fjnrC9TX0fJ8ENb38HZawZha0nqNWh3Y7Dsec99l9VzXiBBAaqhEm00ciJ5Cz ejZ87oIwp+zY7CbyzeweNPTbVTrH+zCb7YpX4slG5owfrliaEGX4xLwaW9bdvt8S8L15 vCUddkEvAKRoc836L5VWx+yvt0LnNMs6BBGPl4J22YXcLaBpQVvZGLVXGEv6GxtkO/5c 0n1g/TwZm/8MT4/AfSlavZBme5JtlugOgxwuUZYYdu21WMULnTRcuul6rxckyYlur6SN IlSv43M2ZRpPU86l3jgpYuNCzK6v2gY6JBHQ/pykYOsY+t3+GPt+2/Ilq3vqIzxqWLka a/xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uyJe6V3Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g26si2559909otk.324.2020.01.08.11.52.51; Wed, 08 Jan 2020 11:53:03 -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=uyJe6V3Q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728630AbgAHQYS (ORCPT + 99 others); Wed, 8 Jan 2020 11:24:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:47112 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbgAHQYS (ORCPT ); Wed, 8 Jan 2020 11:24:18 -0500 Received: from linux-8ccs (x2f7fcda.dyn.telefonica.de [2.247.252.218]) (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 704A02073A; Wed, 8 Jan 2020 16:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578500657; bh=AyZDBjBocC+JhoC3jD/7qgF1YLP3XWBZtmk2w6NbWac=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uyJe6V3QLr8RurNjtkir+jhSsDNMC6vX/zU8V2moHR9Fz16neK8AIDepB+eab7aX+ ln1RmzBoN3lSyws4rXmplzV7polKkGFNp0Pz6qt1DY/JWpUJAtOxdX+VY5YddlpimR SnoyQAvDOaHowFyeg+NxHubnQxjveIzFSChawZDw= Date: Wed, 8 Jan 2020 17:24:12 +0100 From: Jessica Yu To: YueHaibing Cc: mbenes@suse.cz, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/module: Fix memleak in module_add_modinfo_attrs() Message-ID: <20200108162412.GA12869@linux-8ccs> References: <20191228115455.24088-1-yuehaibing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20191228115455.24088-1-yuehaibing@huawei.com> X-OS: Linux linux-8ccs 4.12.14-lp150.12.61-default x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ YueHaibing [28/12/19 19:54 +0800]: >In module_add_modinfo_attrs() if sysfs_create_file() fails >on the first iteration of the loop (so i = 0), we forget to >free the modinfo_attrs. > >Fixes: bc6f2a757d52 ("kernel/module: Fix mem leak in module_add_modinfo_attrs") >Signed-off-by: YueHaibing Applied, thanks! Jessica >--- > kernel/module.c | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/kernel/module.c b/kernel/module.c >index c3770b2..8ec670e 100644 >--- a/kernel/module.c >+++ b/kernel/module.c >@@ -1784,6 +1784,8 @@ static int module_add_modinfo_attrs(struct module *mod) > error_out: > if (i > 0) > module_remove_modinfo_attrs(mod, --i); >+ else >+ kfree(mod->modinfo_attrs); > return error; > } > >-- >2.7.4 > >