public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: wlan-ng: Fix potential double free in skb_ether_to_p80211
@ 2024-09-15 18:58 Mikhail Arkhipov
  2024-09-16  4:12 ` philipp hortmann
  0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Arkhipov @ 2024-09-15 18:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Mikhail Arkhipov, Lynn Lei, linux-staging, linux-kernel,
	lvc-project

Fix a potential double free of the p80211_wep->data pointer in the
skb_ether_to_p80211 function. When encryption fails, the function frees
p80211_wep->data but does not set the pointer to NULL, leading to the
possibility of double freeing the memory if the caller attempts to
free it again (calling function in p80211netdev.c (line 385) attempts
to free this memory again using kfree_sensitive at line 432)

Set p80211_wep->data to NULL after freeing it to ensure that further
attempts to free this pointer are safely handled, preventing a
double free error.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: b5956dd26f84 ("drivers/staging/wlan-ng/p80211conv.c: fixed a
 potential memory leak")
Signed-off-by: Mikhail Arkhipov <m.arhipov@rosa.ru>
---
 drivers/staging/wlan-ng/p80211conv.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 0ff5fda81b05..b2e224e1e33f 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -215,6 +215,7 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
 				    "Host en-WEP failed, dropping frame (%d).\n",
 				    foo);
 			kfree(p80211_wep->data);
+			p80211_wep->data = NULL;
 			return 2;
 		}
 		fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1));
-- 
2.39.3 (Apple Git-146)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-16  4:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-15 18:58 [PATCH] staging: wlan-ng: Fix potential double free in skb_ether_to_p80211 Mikhail Arkhipov
2024-09-16  4:12 ` philipp hortmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox