From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33DEBC2BA83 for ; Fri, 14 Feb 2020 15:50:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 037BD24681 for ; Fri, 14 Feb 2020 15:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581695411; bh=fPl5CA2wmeIK8jarfsPxfk2GQe02TOM2RTLnsYOCum4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kXPulnCvkYBzxUzFTmPRgS6hcBQpyur8FCpkKLUEFdLG+JgNqFeZQdLoMyyN2TAwp S3m77aWqQ3M6OGmp1tuZVD7AsqHLishwJzQYBe2qi+FKabt9uZth5+2FxvbuBB83Ms noFw74h0mfIsqG+ZVKJNSiWp6pBP1xOIQd+uSkr0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730374AbgBNPuJ (ORCPT ); Fri, 14 Feb 2020 10:50:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:53954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730363AbgBNPuI (ORCPT ); Fri, 14 Feb 2020 10:50:08 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 77AF022314; Fri, 14 Feb 2020 15:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581695408; bh=fPl5CA2wmeIK8jarfsPxfk2GQe02TOM2RTLnsYOCum4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y/HPU+EiBE6C9xNlcbtLUibnz5fgFYpA+dD8TwLiS45QQ5TQSOhIpbWprbuT8YZP+ 8TkyseSg3lBccH1Oec3XbLxNGe7a/OlDSmG6rqsT9uxZWwmRcy/3Ra7UmM5Sps4uKQ E10w4jqspNfgraPXv5c6xoKqwUbXMFhtAa7mIGpM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: YueHaibing , Miroslav Benes , Jessica Yu , Sasha Levin Subject: [PATCH AUTOSEL 5.5 056/542] kernel/module: Fix memleak in module_add_modinfo_attrs() Date: Fri, 14 Feb 2020 10:40:48 -0500 Message-Id: <20200214154854.6746-56-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214154854.6746-1-sashal@kernel.org> References: <20200214154854.6746-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: YueHaibing [ Upstream commit f6d061d617124abbd55396a3bc37b9bf7d33233c ] 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") Reviewed-by: Miroslav Benes Signed-off-by: YueHaibing Signed-off-by: Jessica Yu Signed-off-by: Sasha Levin --- kernel/module.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/module.c b/kernel/module.c index b56f3224b161b..8785e31c2dd0f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1781,6 +1781,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.20.1