Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp5436945rdb; Sun, 31 Dec 2023 00:43:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6hes0JyV3HgdVmFiqIotRyf+Ai2ye7Lz7WFU3r4OXpPRz/HSOxFc8HbQww2GxfcA1lELH X-Received: by 2002:ac8:570f:0:b0:428:1e16:3957 with SMTP id 15-20020ac8570f000000b004281e163957mr180745qtw.24.1704012226086; Sun, 31 Dec 2023 00:43:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704012226; cv=none; d=google.com; s=arc-20160816; b=SO0Xrc12n6GAEKvFCN2GwntA92L43mUyGb8PK9AEdKYFMxdquzHYYuTxZfUEZQSd+z 00qLbtQSFSYt2L5hivAi422nnam8Hegk5fdu+akg1XBTYnhAovkFvQZhli/MxWvBDUsL xTBjlL0WIgvYog3IKnN7x8gsFBu0TEzFLoLiXa3wgV2x3U+8dSsP7axF5SWNkodIVZEs KdYofIhAfcw7Rj+rKU+cpG9FV25x1Djmef1JmYuLGt/2pmI56w0nx30YFklPNGzDlC95 CqDAZvAGpW1YN5UStdCrXj0k9WcH+YMjpqjT6GFbm7IbxZ8odThEjuFkrL+i/GgHe4Ta +1Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=nmscrQHcXWxEmgVPSOcRAU+OKQWLwPr1G06r3jrE0Gw=; fh=mHUc5t111K6blR9l7YFjk4JXmM1O1ZpTKprQuCYlFtM=; b=GXyoo1MrK37AmS/6ssh1ynDcgT2rcaBXvIL/CR5Hui9zzjTke1Hta8tK+ayg5elZzD QefPbemVVvKluPq0hoDDWcCXJF2nzB9FZhJYHdD9qf9S9+9DWvkb3jcj4COQ6cv46taE tTTLE5EpxFKUFDfbfBpHqbgrmn9/lZOSTpj7o0G+nAQJhDob711UmlfUOE6k4EF+Pxg6 JicsG4xojs+Nac5xTX7ASUMk7iO9RFrDuGDci0pc16Po9WFMtPiBow6Qm9raEuOC7wVz N/GlpEG22YGw8Qv76jEWRhjjeX+BzMxDN1wPHaaxnraHC+9HzLJBSeKzZYrEHozCFIB8 L2gA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=DK3xL9UK; spf=pass (google.com: domain of linux-kernel+bounces-13660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y18-20020a0cd992000000b0067f9161d2e0si20078977qvj.423.2023.12.31.00.43.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Dec 2023 00:43:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@web.de header.s=s29768273 header.b=DK3xL9UK; spf=pass (google.com: domain of linux-kernel+bounces-13660-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13660-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=web.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D1D551C20AF4 for ; Sun, 31 Dec 2023 08:43:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F29511C2F; Sun, 31 Dec 2023 08:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="DK3xL9UK" X-Original-To: linux-kernel@vger.kernel.org Received: from mout.web.de (mout.web.de [212.227.15.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 261EE20F0; Sun, 31 Dec 2023 08:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1704012207; x=1704617007; i=markus.elfring@web.de; bh=Y0zWZgj6Y0K0bkgqyGjCt7nG5v2aUOSugrldJ+nSJyQ=; h=X-UI-Sender-Class:Date:Subject:From:To:Cc:References: In-Reply-To; b=DK3xL9UKgS34OjC/P921kKVslC2HvqyRcPR+9BfDMbZ5Z6puwnA7xAMvOKrcZjUH +C8xuK8wMgYkQCiX+hTlnGMa112CfKxbq+gMGdxAz4Ar/lPGD41W/WbARCYsAaRUX JXNeSsPPlciZ+HF1/Ko+UCBZCbQHCpSS9BE/DQkcwns1YPgKDmZfV3CEMrvboDVwc nJNrdUqHkbjYRRSoNjPx7Z7QBHnOi8bwJYqWrJNvUj5yDtaYy5vaTrRvh8zpSFxaX 5SFqRbG/Cc6K0BYEvpoi10jURm4Y97NcFxie3DoTxksquZfkwnNJqCT6vh3nGusVh aOOGU8zly6ODyX13iQ== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.90.95]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1M2Phi-1rNhxp31o6-004HsL; Sun, 31 Dec 2023 09:43:27 +0100 Message-ID: Date: Sun, 31 Dec 2023 09:43:27 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/3] gcov: Improve exception handling in add_links() Content-Language: en-GB From: Markus Elfring To: Peter Oberparleiter , kernel-janitors@vger.kernel.org Cc: LKML References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:266UXnCFnJs1UhXDnxzgQk0WSNxoTBvL4Ectx5t/OyYBkhFpbMz q9d7wTo/cpcFYxdrHeust6Bsm41z8foE9EaQlGsVN0OdKWvCEc2D6+Sb7uNr345poqRd/yU Zmsu/snErGDNozlYGprkJoMT04N49gL92i+3n3Nu4eXdMlJTB9vACJnVBsljKbHXHdNTawu 88qxBY0f3/BZxoGkVFRzQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:G+N9Oq2OJi8=;8Tm1thXBTbg3AdxG9He9+sInVuI U5TSfmRZFFYED0ouc5m+aBudgP5iqZRhx+SIMGbXP9Xfu4XTsg5WcbCjaIBBUff4ygFeRp+LT djCiOnSsmaDztE5Iqv4391AyrbXm/7w9w3KkUhDiEFqHtg84Eu41vBokLKFWoAk98HJFd/Iyc xNqySMm6/rUrkFVg56F8xLGWEgJLdNr3LA46+RNoP4BmlRKlDUNr9FVIILHxWetj9I9K6JiTP KKRquj0Z3VKB8m9MjI0nUFh6mADRFEFpg3grQIT8Y8NlX3F0t9ItT9rA4TLJios4qnVvxvvBJ bIj+o0sYi3aWphbnWFSQsgFNUsSHmO+OEEbtySseaLEQpeOFld44Ui2+nGeRBfFmy2JVBVyF3 hs76WaXssa/bJaoVTIY+7MSa/gL8Wu42YCVti5CAT9SUSPFu8RimICqK+s3WrK4VNB+LAqJ9Y XgmGH9+hY3/2hUaYehPjSeKSf6U6ecJKHiBbgIDvdOLPHk5rUSZAI/aDtCmQ0Gxo5zvgypnRo Qz0srOtS3R8vNRJ/7HP34uurPUyWeOytmg9fSpq1aTcO/pBO4RdvT9vU2q4YiOI41FCb7bCf4 5EOQlqlbF+MX7rGncjLn0dNlxZ7I/B4N9BnFR+qUMotfElLPbdYcx7uzf3DiyVtXpdLFB0aWB Zd56tmaaD5tNlc6sWAl7GDvLE0VKohNegHgXUL1X8MDmMV+2Oy/Wfth6uBgfoNpM49yMOJgzx TGDCMdsjxMeKITDi+B9nKU4H7CzKmN/7riiLV3VDvlqo2NOG0sZ8QxTGIeV4gRjh2W/yVekdA c1FTmScOVe6h/UX/skp7VAYKaW4zjRhLpFQng+AhTpV+3jzqk7tkrlGbCEPgTQ/E33Xjwq+0p roef4hExnbsISdt9Qbjv1WLwl7XP0F0jCYMRyGxRPUBU2QNBNWqLiMk7U4C3nt0YuvHzd6Vba z1SJfw== From: Markus Elfring Date: Sun, 31 Dec 2023 09:23:50 +0100 The kfree() function was called in one case by the add_links() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. Thus use another label. Signed-off-by: Markus Elfring =2D-- kernel/gcov/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c index 10916c70fad9..80c221bb7f20 100644 =2D-- a/kernel/gcov/fs.c +++ b/kernel/gcov/fs.c @@ -490,7 +490,8 @@ static void add_links(struct gcov_node *node, struct d= entry *parent) gcov_info_filename(get_node_info(node)), &gcov_link[i]); if (!target) - goto out_err; + goto remove_links; + basename =3D kbasename(target); if (basename =3D=3D target) goto out_err; @@ -502,6 +503,7 @@ static void add_links(struct gcov_node *node, struct d= entry *parent) return; out_err: kfree(target); +remove_links: while (i-- > 0) debugfs_remove(node->links[i]); kfree(node->links); =2D- 2.43.0