Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6476729rdb; Tue, 2 Jan 2024 03:24:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdn85mnQmiFYOTXvRjh046ocRYc1Uh5LQYvNm/Yx9pgbLaGP01Ib8a2bYXEAzQ7HeAYS31 X-Received: by 2002:a05:6a20:671f:b0:196:22b8:a919 with SMTP id q31-20020a056a20671f00b0019622b8a919mr9594803pzh.24.1704194686793; Tue, 02 Jan 2024 03:24:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704194686; cv=none; d=google.com; s=arc-20160816; b=dYaHmk2+nkuIOZvbVfY7laoinsC6YiwdOMI86ueUXQlDgwVDLRh6zsNrmlKgFe5bI9 idKrAvqLLBC6/JDGnGk8ntxJ9V+h9TH+ylkrKaj9phW5V7BY6hLPGL+8UqY1NtUOPILG KYcxTXthf6ZqIPjcMAnPGcG7fw4JWSTGQx+XyTCYnArdgSWW8czKtjTm+sCtjCIfHNJ5 kzstGHYFsdTNiWtUBy/u5d8Sr2HIu7AfqKzVSk4+GWt55JQZaMB+SZ3CMsa1KjvTrxg8 S53HP5AHCfKoFJTDSq/QOr4YflNIpz33Dbxowfc+1Mlm4TdyWOSEx0+nArvvlAoyjhNt TQoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RL4p8JTgWtUMp+LSFYGDq2LgzfnsXq2WPu5q9VKoeO4=; fh=jj7v9eOwpc0/U5FSF0S/3fncoqwulC6cJUEmPJX6syQ=; b=Ad3iAjf/DEpCyO6tsiogJUh4TuQTQMqZH2hgKTIkdThSj/VpV7iMjwhZmq9Gg8/rMV vMrBUz6u+ZL70ur6rB6BJS7XdITSdb/ewn0jwGFzosHKs83OyY9sEHhKhPb2UHJP2sFb ZV+AhJOxYeF2gWgq4cjigJEPO1WhqcwASveArEMK6f3w+ixN7fGdeKosTDqbh5z692vk RTETQKafvi1j1gRoQet+YfrmiYmWWIK2ooSCJO6SixLzAIKGXKxg7CSiG2zTgCud3Sxr ks5roKZLtCxFo0TC1B08Ybhoj/+0pK1iRVcei3x/2d6emKTrjJ2zTXgxeOLsaMdtRNaN z4ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@narfation.org header.s=20121 header.b=eGmXqasC; spf=pass (google.com: domain of linux-kernel+bounces-14286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=narfation.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t3-20020a628103000000b006dab03e6bd8si22918pfd.118.2024.01.02.03.24.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 03:24:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@narfation.org header.s=20121 header.b=eGmXqasC; spf=pass (google.com: domain of linux-kernel+bounces-14286-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=narfation.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 12289B20E96 for ; Tue, 2 Jan 2024 11:24:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21543E574; Tue, 2 Jan 2024 11:24:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b="eGmXqasC" X-Original-To: linux-kernel@vger.kernel.org Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) (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 22B4BEAC0; Tue, 2 Jan 2024 11:24:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1704194648; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=RL4p8JTgWtUMp+LSFYGDq2LgzfnsXq2WPu5q9VKoeO4=; b=eGmXqasCdYtT4c3TgAwsOFFN82HooJbJOEvq++G/iC28O2BLpcbK4C+wGyfC2Uje+tvntd igtbeTIfHijeeGG1K3Uvr2hCEc582bPn5wk6RwrpaV27ttveqgQ8I4h1ScyWFnXRODeP9x KHo/8w0IfIJoqNIIEkj1/w8h0E/tm5Y= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, Antonio Quartulli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marek Lindner , Paolo Abeni , Simon Wunderlich , Markus Elfring Cc: LKML Subject: Re: [PATCH 2/2] batman-adv: Improve exception handling in batadv_throw_uevent() Date: Tue, 02 Jan 2024 12:24:05 +0100 Message-ID: <4889340.31r3eYUQgx@sven-l14> In-Reply-To: References: <8588cafe-3c61-40a6-b071-0877632a2a1e@web.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart4538693.LvFx2qVVIh"; micalg="pgp-sha512"; protocol="application/pgp-signature" --nextPart4538693.LvFx2qVVIh Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii"; protected-headers="v1" From: Sven Eckelmann Cc: LKML Date: Tue, 02 Jan 2024 12:24:05 +0100 Message-ID: <4889340.31r3eYUQgx@sven-l14> In-Reply-To: MIME-Version: 1.0 On Tuesday, 2 January 2024 08:12:56 CET Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 2 Jan 2024 07:52:21 +0100 > > The kfree() function was called in up to three cases by > the batadv_throw_uevent() 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. > > * Reorder kfree() calls at the end. > > Signed-off-by: Markus Elfring Acked-by: Sven Eckelmann > --- > net/batman-adv/main.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c > index 5fc754b0b3f7..75119f1ffccc 100644 > --- a/net/batman-adv/main.c > +++ b/net/batman-adv/main.c > @@ -691,29 +691,31 @@ int batadv_throw_uevent(struct batadv_priv *bat_priv, enum batadv_uev_type type, > "%s%s", BATADV_UEV_TYPE_VAR, > batadv_uev_type_str[type]); > if (!uevent_env[0]) > - goto out; > + goto report_error; > > uevent_env[1] = kasprintf(GFP_ATOMIC, > "%s%s", BATADV_UEV_ACTION_VAR, > batadv_uev_action_str[action]); > if (!uevent_env[1]) > - goto out; > + goto free_first_env; > > /* If the event is DEL, ignore the data field */ > if (action != BATADV_UEV_DEL) { > uevent_env[2] = kasprintf(GFP_ATOMIC, > "%s%s", BATADV_UEV_DATA_VAR, data); > if (!uevent_env[2]) > - goto out; > + goto free_second_env; > } > > ret = kobject_uevent_env(bat_kobj, KOBJ_CHANGE, uevent_env); > -out: > - kfree(uevent_env[0]); > - kfree(uevent_env[1]); > kfree(uevent_env[2]); > +free_second_env: > + kfree(uevent_env[1]); > +free_first_env: > + kfree(uevent_env[0]); > > if (ret) > +report_error: > batadv_dbg(BATADV_DBG_BATMAN, bat_priv, > "Impossible to send uevent for (%s,%s,%s) event (err: %d)\n", > batadv_uev_type_str[type], > -- > 2.43.0 > > --nextPart4538693.LvFx2qVVIh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part. Content-Transfer-Encoding: 7Bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF10rh2Elc9zjMuACXYcKB8Eme0YFAmWT8lUACgkQXYcKB8Em e0ZtIA//eZtvK8xgUCk7KXnL6m/xB/Hnlsa817um4kK3xG+JO1hmlgxNsNJfu0HT VIP0Ca/QY7GRewIOz2fT60YCffgVQeht30bVdI3D7U6du5/nd6Q3JRzw8WaFuDxo MBIvVoqtNCK3YNBjKhYILq1X/lmxgvE+4J/1n94/QQWlJ9lgZthE2JWVwbMfDa+Q USyZI6ftogWsk9TKrt5cgWuQRrps3qtjnHUmgBNFXfWjwsRQUtjWzE960Y6au2tH fAqTrBW7M18RE+yDKQUjnmlpETnwBLCCcudS2cZBmx9EZL4TQEdJ4T+Ka8e9iPwV M37MJh/h+mwbxKIhv0vPnuvpBHZzQ+3opNCgIGTpS5YExATFMCIVXMeuN+kjVfC3 X1iHjqRagGxcqpQtzaUcgYsZ4/elr5ODM4GH2VzH5phqb5iS0u64K+lmuWqO/Bsx hi7klW9+mKcrVgyeM5r83VcP9Ea+wS/3vhQBTPK4X3da71oqPq0X+2/qOYlzreBq LIpWu9BdpkKp5NHoAL7yyxOfm8hIjGCY1EXWUsKyb9Zs08Etqr4thHJtxxTNzhM1 2ulCCmn8NNK/PzvguYQxIbXiJiK9U7bfzZoKbYSPRTEvd2xM2RxMrgZH94swmFYD SNNMTa3ccaynMy/E/KB0/uD2ktF1PHs6739YdB6ivv7VIZTKqRI= =sz9M -----END PGP SIGNATURE----- --nextPart4538693.LvFx2qVVIh--