All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Markus Elfring <elfring@users.sourceforge.net>,
	Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>,
	Sasha Levin <sashal@kernel.org>,
	mareklindner@neomailbox.ch, a@unstable.cc, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 6.8 05/68] batman-adv: Improve exception handling in batadv_throw_uevent()
Date: Fri, 29 Mar 2024 08:25:01 -0400	[thread overview]
Message-ID: <20240329122652.3082296-5-sashal@kernel.org> (raw)
In-Reply-To: <20240329122652.3082296-1-sashal@kernel.org>

From: Markus Elfring <elfring@users.sourceforge.net>

[ Upstream commit 5593e9abf1cf2bf096366d8c7fd933bc69d561ce ]

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 <elfring@users.sourceforge.net>
Acked-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 5fc754b0b3f7f..75119f1ffcccf 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


  parent reply	other threads:[~2024-03-29 12:27 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 12:24 [PATCH AUTOSEL 6.8 01/68] wifi: ath9k: fix LNA selection in ath_ant_try_scan() Sasha Levin
2024-03-29 12:24 ` [PATCH AUTOSEL 6.8 02/68] wifi: rtw89: fix null pointer access when abort scan Sasha Levin
2024-03-29 12:24 ` [PATCH AUTOSEL 6.8 03/68] bnx2x: Fix firmware version string character counts Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 04/68] batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data() Sasha Levin
2024-03-29 12:25 ` Sasha Levin [this message]
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 06/68] arm64: dts: qcom: Add support for Xiaomi Redmi Note 9S Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 07/68] net: stmmac: dwmac-starfive: Add support for JH7100 SoC Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 08/68] net: phy: phy_device: Prevent nullptr exceptions on ISR Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 09/68] wifi: rtw89: pci: validate RX tag for RXQ and RPQ Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 10/68] wifi: rtw89: pci: enlarge RX DMA buffer to consider size of RX descriptor Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 11/68] VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 12/68] wifi: iwlwifi: pcie: Add the PCI device id for new hardware Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 13/68] arm64: dts: qcom: qcm6490-idp: Add definition for three LEDs Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 14/68] net: dsa: qca8k: put MDIO controller OF node if unavailable Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 15/68] arm64: dts: ti: Makefile: Add HDMI audio check for AM62A7-SK Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 16/68] arm64: dts: qcom: qrb2210-rb1: disable cluster power domains Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 17/68] printk: For @suppress_panic_printk check for other CPU in panic Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 18/68] printk: Add this_cpu_in_panic() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 19/68] printk: Avoid non-panic CPUs writing to ringbuffer Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 20/68] panic: Flush kernel log buffer at the end Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 21/68] dump_stack: Do not get cpu_sync for panic CPU Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 22/68] wifi: iwlwifi: pcie: Add new PCI device id and CNVI Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 23/68] cpuidle: Avoid potential overflow in integer multiplication Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 24/68] ARM: dts: rockchip: fix rk3288 hdmi ports node Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 25/68] ARM: dts: rockchip: fix rk322x " Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 26/68] arm64: dts: rockchip: fix rk3328 " Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 27/68] arm64: dts: rockchip: fix rk3399 " Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 28/68] net: add netdev_lockdep_set_classes() to virtual drivers Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 29/68] arm64: dts: qcom: qcs6490-rb3gen2: Declare GCC clocks protected Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 30/68] pmdomain: ti: Add a null pointer check to the omap_prm_domain_init Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 31/68] pmdomain: imx8mp-blk-ctrl: imx8mp_blk: Add fdcc clock to hdmimix domain Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 32/68] arm64: dts: sc8280xp: correct DMIC2 and DMIC3 pin config node names Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 33/68] arm64: dts: sm8450: " Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 34/68] arm64: dts: sm8550: " Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 35/68] arm64: dts: sm8650: " Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 36/68] ACPI: resource: Add IRQ override quirk for ASUS ExpertBook B2502FBA Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 37/68] ionic: set adminq irq affinity Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 38/68] net: skbuff: add overflow debug check to pull/push helpers Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 39/68] net: mdio: mdio-bcm-unimac: Manage clock around I/O accesses Sasha Levin
2024-04-02 12:41   ` Florian Fainelli
2024-04-07 23:37     ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 40/68] firmware: tegra: bpmp: Return directly after a failed kzalloc() in get_filename() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 41/68] wifi: brcmfmac: Add DMI nvram filename quirk for ACEPC W5 Pro Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 42/68] wifi: mt76: mt7915: add locking for accessing mapped registers Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 43/68] wifi: mt76: mt7996: disable AMSDU for non-data frames Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 44/68] wifi: mt76: mt7996: add locking for accessing mapped registers Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 45/68] ACPI: x86: Move acpi_quirk_skip_serdev_enumeration() out of CONFIG_X86_ANDROID_TABLETS Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 46/68] ACPI: x86: Add DELL0501 handling to acpi_quirk_skip_serdev_enumeration() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 47/68] pstore/zone: Add a null pointer check to the psz_kmsg_read Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 48/68] tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 49/68] net: pcs: xpcs: Return EINVAL in the internal methods Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 50/68] dma-direct: Leak pages on dma_set_decrypted() failure Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 51/68] wifi: ath11k: decrease MHI channel buffer length to 8KB Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 52/68] iommu/arm-smmu-v3: Hold arm_smmu_asid_lock during all of attach_dev Sasha Levin
2024-03-29 12:25   ` Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 53/68] sparc: vdso: Disable UBSAN instrumentation Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 54/68] cpufreq: Don't unregister cpufreq cooling on CPU hotplug Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 55/68] overflow: Allow non-type arg to type_max() and type_min() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 56/68] sh: Fix build with CONFIG_UBSAN=y Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 57/68] wifi: iwlwifi: Add missing MODULE_FIRMWARE() for *.pnvm Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 58/68] wifi: cfg80211: check A-MSDU format more carefully Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 59/68] btrfs: preallocate temporary extent buffer for inode logging when needed Sasha Levin
2024-04-02 13:35   ` David Sterba
2024-04-03  0:33     ` Sasha Levin
2024-04-04 18:58       ` David Sterba
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 60/68] btrfs: handle chunk tree lookup error in btrfs_relocate_sys_chunks() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 61/68] btrfs: export: handle invalid inode or root reference in btrfs_get_parent() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 62/68] btrfs: send: handle path ref underflow in header iterate_inode_ref() Sasha Levin
2024-03-29 12:25 ` [PATCH AUTOSEL 6.8 63/68] ice: use relative VSI index for VFs instead of PF VSI number Sasha Levin
2024-03-29 12:25   ` [Intel-wired-lan] " Sasha Levin
2024-03-29 12:26 ` [PATCH AUTOSEL 6.8 64/68] net/smc: reduce rtnl pressure in smc_pnet_create_pnetids_list() Sasha Levin
2024-03-29 12:26 ` [PATCH AUTOSEL 6.8 65/68] netdev: let netlink core handle -EMSGSIZE errors Sasha Levin
2024-03-29 12:26 ` [PATCH AUTOSEL 6.8 66/68] Bluetooth: btintel: Fix null ptr deref in btintel_read_version Sasha Levin
2024-03-29 12:26 ` [PATCH AUTOSEL 6.8 67/68] Bluetooth: btmtk: Add MODULE_FIRMWARE() for MT7922 Sasha Levin
2024-03-29 12:26   ` Sasha Levin
2024-03-29 12:26 ` [PATCH AUTOSEL 6.8 68/68] Bluetooth: Add new quirk for broken read key length on ATS2851 Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240329122652.3082296-5-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=a@unstable.cc \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=elfring@users.sourceforge.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=sven@narfation.org \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.