From patchwork Fri Dec 29 11:40:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13506452 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C365C46CD3 for ; Fri, 29 Dec 2023 11:40:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02BE36B0118; Fri, 29 Dec 2023 06:40:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1DC06B0119; Fri, 29 Dec 2023 06:40:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE5166B011A; Fri, 29 Dec 2023 06:40:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CC5C26B0118 for ; Fri, 29 Dec 2023 06:40:17 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 9AF331602EB for ; Fri, 29 Dec 2023 11:40:17 +0000 (UTC) X-FDA: 81619662474.18.D3A0491 Received: from mout.web.de (mout.web.de [212.227.17.11]) by imf15.hostedemail.com (Postfix) with ESMTP id 7878BA001D for ; Fri, 29 Dec 2023 11:40:15 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=aJPqrjSi; dmarc=pass (policy=quarantine) header.from=web.de; spf=pass (imf15.hostedemail.com: domain of Markus.Elfring@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=Markus.Elfring@web.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703850015; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tM3Q9ugSi0fR0S/jHVgcDC11P47mb6LeoAXv0v+hYpo=; b=cFkAPgubKihKSsmwmW0c3U/ciF+V0QINrvJeWrhJsFKi/th/CRbaSUzAMyOrR6INq6ESnH v3ycj4BB3JxYChVAivyYmnR5sHRYiqiLR8+p9R4i99+KPvL2VVGkuPBt37B770anRsvIBH r9sals+LdPLA01sYH9MUq5DT4wgDTuU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=web.de header.s=s29768273 header.b=aJPqrjSi; dmarc=pass (policy=quarantine) header.from=web.de; spf=pass (imf15.hostedemail.com: domain of Markus.Elfring@web.de designates 212.227.17.11 as permitted sender) smtp.mailfrom=Markus.Elfring@web.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703850015; a=rsa-sha256; cv=none; b=osERe2Sfyw/2UGzSQLea+MBoFMr4HA3xorEvxeHXM0VbP0NMWk9GTHethX6o5tREblKPfQ Fb60tcQ6xogry7/1uuUTiA7FfH4f03dvxSOAvxqQO9sHREHonuXBdBor+Gerq850G1aPS7 ztANIEwhRoOTWmScrLigjiVNWAJ+vP4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1703850014; x=1704454814; i=markus.elfring@web.de; bh=UHYDVlvrvWOSRegpd/VlmhDK9J+cjiRSKZxQmGzus70=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References: In-Reply-To; b=aJPqrjSi6IOnqog50GT0ZJnWPo6T9J/P8/98PMs/aZq9AaqbnbRRFoyxlQVfP006 v5MMUwNFH5OLUzpcsflmb0UvK+VxvwsFMHmVdwYpGHzYBvLI8mubGl/QdyQi9FEmd QdktHUWIERl4+M/A8klFCm8rl8NvCjxCVV66yBcIj5F7P1RyHMtSea+/010fGLrNp IIqsp7sG5x0CBBKKJsaQhT6LjbhO3AY583hbHyHRg8ussdU+SWJFl03VURkheIxaw hRNM0L+xTpiNa9s13KjMsfrj4DqMbVyamEWR6Js0+c5/tzwH/PP91pC/z3w41r2Zd TiLThe8+2Zy9dCVxMA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MuFD5-1qyVCi3oGz-00uPL1; Fri, 29 Dec 2023 12:40:13 +0100 Message-ID: Date: Fri, 29 Dec 2023 12:40:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] hugetlbfs: Improve exception handling in hugetlbfs_fill_super() Content-Language: en-GB From: Markus Elfring To: linux-mm@kvack.org, kernel-janitors@vger.kernel.org, Muchun Song Cc: LKML References: <9ce3f553-24bc-4ecd-ac5e-7ba27caeff57@web.de> In-Reply-To: <9ce3f553-24bc-4ecd-ac5e-7ba27caeff57@web.de> X-Provags-ID: V03:K1:QPFYYP3aCa+simUrAouMcW9QcK5xtcbjpkdZdiHYFJ+XmWYAPxj MAk7mAaomOMcC7dd+4bk3MS+xC1kiLqz9IwL3wFjPXgPy+wVyiqZr1CPu6ie84PIjbVEegE aD2E60sZGpEVmu/s0Mm1yTJDgBP0jEAyyFvpfmDrXsbvQjDvH5dII33uoh+IEhUl7LAOb9Y B7aEwLeGFLrhd/rtCVCLQ== UI-OutboundReport: notjunk:1;M01:P0:R9CIMRG8WIo=;I1ZtYzDfS2V0P2/oJTEFDGzc7mE waxeyt9HIlp9n4gvok5KWoDW1+h9mpIgpqv2Ie0cP4Vw1waLrSMVN6RObZX4jyCn3vFOF6YqP g6XAsPN2GrLIxb59gmwUIO3BLvHWseyR6D4hIVtKMvpLQzNyhnrl7M9hthpRy46Fb3YQoVcxf kgL9qQwbSKK89YEpXQ0aYTmI/a9c39lSznzGb1xVGaqDoC633AIi+BF3Cl+37DwbiIuqb54Cp 6y0XXzW3diz0T+w9GCf+nTGyhL7FagbzcIdIw7toB8UQ4r5TUo0TKnl+QEzyo39WdiythCO/U BZNzTgh8ha4XvlOC3m7W4sMAvjHkhSL5LqENUMZDxzz9L3+PEHVKY5irR4+objIaAj3n3zKIZ 9/aC1SjFl/yQKOWLSPZxsZoBl6KFdU0wPHCbE8+hLHjk+ylv1oaPgGtcOY65Sw8TcDsk5KKFw FUHVwzmu0DMshBq8eB0LZ9ti3nk8C8IVoUkZtV23Gv/VvV85WVeikZy3bjedcEKOHzA9q01AE whGROhfkz1oSCwb2JEkTMYL35qH9YxeUwZWKwAgjf+2aiE8fnyGmuO5JOvtX/96QbpDKPbUJZ IEN0D+XErBg1mOZPprVfcTWqewzsZ5Q/qloNch8itL3Y58JH+KwRrc9pcugxVj9nrG57C+CLW nl0sZ2rl64GoRN5nSZyKgikgyBUkYBSpp9dExGyIgaQIkI0p3m1gr1sAbUqyZLIenau0JSnZj En4Gy9iGOpAIcyVrtxvJmnbDXM93LVsWBoUTjoUWLphEZHshMdckGT9/EoU7T7Pj87PjYfwWs cESdoxfqo+UI+nRTrzkZITwVkDvqLClv4TWLigVwgXZ3Wivr6X3NwLC67NGsIOtXMRfxrheqv sAninmNQwYMjP/GiOE53yfyOusvU3rOUpngN44XCAZNZbgrd0U82a34bT8gNS3LVkY/ENuqi8 AJFvoA== X-Rspamd-Queue-Id: 7878BA001D X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: h5b3p7nix6j3oqp9d1d6jwf8dhrz9kdt X-HE-Tag: 1703850015-456677 X-HE-Meta: U2FsdGVkX1/S1ErLGP6Ul5/DzE+aCwLPQaSoiG4x+I62AbQFWU8qX61J3Ux/wgoyfdfoLH8PWyE/x2tPM8GF+sODu6C+V/wjdkcJFCfSdlkVshzU93NEex6cjI/iY9mXIeMMVdoagiPNYBlvVo4iAdFtQWIpZBnbhilY+2CFBCBHbkW0nHGZv7Dpt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aAqM5wHKab5FgJcFCBTgap3ame+30NU+aDRw3mSXFqyvAgmwPoPjKv4/pQtPgKNZMhiMrSUgkX4PNAackybobo3W+Tuak86Pq X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Markus Elfring Date: Fri, 29 Dec 2023 11:46:32 +0100 The kfree() function was called in one case by the hugetlbfs_fill_super() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. Thus adjust jump targets. Signed-off-by: Markus Elfring --- fs/hugetlbfs/inode.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) -- 2.43.0 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 24401a5046dd..5687ec574dc4 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1483,7 +1483,7 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc) ctx->max_hpages, ctx->min_hpages); if (!sbinfo->spool) - goto out_free; + goto free_sbinfo; } sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_blocksize = huge_page_size(ctx->hstate); @@ -1499,10 +1499,12 @@ hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_stack_depth = FILESYSTEM_MAX_STACK_DEPTH; sb->s_root = d_make_root(hugetlbfs_get_root(sb, ctx)); if (!sb->s_root) - goto out_free; + goto free_spool; return 0; -out_free: + +free_spool: kfree(sbinfo->spool); +free_sbinfo: kfree(sbinfo); return -ENOMEM; }