From: greearb@candelatech.com
To: linux-wireless@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH wireless-next v2 04/28] wifi: mac80211: Check debugfs creation return values.
Date: Thu, 12 Mar 2026 10:00:02 -0700 [thread overview]
Message-ID: <20260312170026.285494-5-greearb@candelatech.com> (raw)
In-Reply-To: <20260312170026.285494-1-greearb@candelatech.com>
From: Ben Greear <greearb@candelatech.com>
Add return error checking for the debugfs directory create
calls. Assign error pointers to NULL instead of potential error
codes that the create logic may return.
Signed-off-by: Ben Greear <greearb@candelatech.com>
---
net/mac80211/debugfs.c | 11 +++++++++++
net/mac80211/debugfs_key.c | 6 ++++++
net/mac80211/debugfs_netdev.c | 33 +++++++++++++++++++++++++++++++++
net/mac80211/debugfs_sta.c | 15 +++++++++++++++
4 files changed, 65 insertions(+)
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index e8d0a8b71d59..1f428f8a7633 100644
--- a/net/mac80211/debugfs.c
+++ b/net/mac80211/debugfs.c
@@ -680,6 +680,12 @@ void debugfs_hw_add(struct ieee80211_local *local)
return;
local->debugfs.keys = debugfs_create_dir("keys", phyd);
+ if (IS_ERR(local->debugfs.keys)) {
+ pr_err("Failed to create local keys debugfs dir, rv: %ld phyd: 0x%px\n",
+ (long)(local->debugfs.keys), phyd);
+ local->debugfs.keys = NULL;
+ return;
+ }
DEBUGFS_ADD(total_ps_buffered);
DEBUGFS_ADD(wep_iv);
@@ -705,6 +711,11 @@ void debugfs_hw_add(struct ieee80211_local *local)
phyd, &local->aql_threshold);
statsd = debugfs_create_dir("statistics", phyd);
+ if (IS_ERR(statsd)) {
+ pr_err("Failed to create local stats debugfs dir, rv: %ld phyd: 0x%px\n",
+ (long)(statsd), phyd);
+ return;
+ }
#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
DEBUGFS_STATS_ADD(dot11TransmittedFragmentCount);
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c
index 117f58af5ff9..670bcfa8c4ed 100644
--- a/net/mac80211/debugfs_key.c
+++ b/net/mac80211/debugfs_key.c
@@ -335,6 +335,12 @@ void ieee80211_debugfs_key_add(struct ieee80211_key *key)
keycount++;
key->debugfs.dir = debugfs_create_dir(buf,
key->local->debugfs.keys);
+ if (IS_ERR(key->debugfs.dir)) {
+ pr_err("Failed to create key debugfs dir, rv: %ld phyd: 0x%px\n",
+ (long)(key->debugfs.dir), key->local->debugfs.keys);
+ key->debugfs.dir = NULL;
+ return;
+ }
sta = key->sta;
if (sta) {
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index f3c6a41e4911..51d2ae232a85 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -882,6 +882,11 @@ static void add_mesh_stats(struct ieee80211_sub_if_data *sdata)
{
struct dentry *dir = debugfs_create_dir("mesh_stats",
sdata->vif.debugfs_dir);
+ if (IS_ERR(dir)) {
+ sdata_err(sdata, "Failed to create mesh stats dir, rv: %ld vif dir: 0x%px\n",
+ (long)(dir), sdata->vif.debugfs_dir);
+ return;
+ }
#define MESHSTATS_ADD(name)\
debugfs_create_file(#name, 0400, dir, sdata, &name##_ops)
@@ -897,6 +902,11 @@ static void add_mesh_config(struct ieee80211_sub_if_data *sdata)
{
struct dentry *dir = debugfs_create_dir("mesh_config",
sdata->vif.debugfs_dir);
+ if (IS_ERR(dir)) {
+ sdata_err(sdata, "Failed to create mesh config dir, rv: %ld vif dir: 0x%px\n",
+ (long)(dir), sdata->vif.debugfs_dir);
+ return;
+ }
#define MESHPARAMS_ADD(name) \
debugfs_create_file(#name, 0600, dir, sdata, &name##_ops)
@@ -1003,10 +1013,25 @@ static void ieee80211_debugfs_add_netdev(struct ieee80211_sub_if_data *sdata,
sprintf(buf, "netdev:%s", sdata->name);
sdata->vif.debugfs_dir = debugfs_create_dir(buf,
sdata->local->hw.wiphy->debugfsdir);
+
+ if (IS_ERR(sdata->vif.debugfs_dir)) {
+ sdata_err(sdata, "Failed to create netdev dir, rv: %ld name: %s wiphy dir: 0x%px\n",
+ (long)(sdata->vif.debugfs_dir), buf, sdata->local->hw.wiphy->debugfsdir);
+ sdata->vif.debugfs_dir = NULL;
+ return;
+ }
+
/* deflink also has this */
sdata->deflink.debugfs_dir = sdata->vif.debugfs_dir;
+
sdata->debugfs.subdir_stations = debugfs_create_dir("stations",
sdata->vif.debugfs_dir);
+ if (IS_ERR(sdata->debugfs.subdir_stations)) {
+ sdata_err(sdata, "Failed to create netdev subdir-stations dir, rv: %ld wiphy dir: 0x%px\n",
+ (long)(sdata->debugfs.subdir_stations), sdata->vif.debugfs_dir);
+ sdata->debugfs.subdir_stations = NULL;
+ return;
+ }
add_files(sdata);
if (!mld_vif)
add_link_files(&sdata->deflink, sdata->vif.debugfs_dir);
@@ -1058,6 +1083,14 @@ void ieee80211_link_debugfs_add(struct ieee80211_link_data *link)
debugfs_create_dir(link_dir_name,
link->sdata->vif.debugfs_dir);
+ if (IS_ERR(link->debugfs_dir)) {
+ sdata_err(link->sdata, "Failed to create debugfs dir, rv: %ld link-dir-name: %s vif dir: 0x%px\n",
+ (long)(link->debugfs_dir), link_dir_name,
+ link->sdata->vif.debugfs_dir);
+ link->debugfs_dir = NULL;
+ return;
+ }
+
DEBUGFS_ADD(link->debugfs_dir, addr);
add_link_files(link, link->debugfs_dir);
}
diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index ef75255d47d5..23cb2099e3b3 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -1250,6 +1250,12 @@ void ieee80211_sta_debugfs_add(struct sta_info *sta)
* dir might still be around.
*/
sta->debugfs_dir = debugfs_create_dir(mac, stations_dir);
+ if (IS_ERR(sta->debugfs_dir)) {
+ sdata_err(sdata, "Failed to create sta debugfs dir, rv: %ld name: %s stations dir: 0x%px\n",
+ (long)(sta->debugfs_dir), mac, stations_dir);
+ sta->debugfs_dir = NULL;
+ return;
+ }
DEBUGFS_ADD(flags);
DEBUGFS_ADD(aid);
@@ -1303,6 +1309,15 @@ void ieee80211_link_sta_debugfs_add(struct link_sta_info *link_sta)
debugfs_create_dir(link_dir_name,
link_sta->sta->debugfs_dir);
+ if (IS_ERR(link_sta->debugfs_dir)) {
+ sdata_err(link_sta->sta->sdata,
+ "Failed to create link-sta debugfs dir, rv: %ld name: %s stations dir: 0x%px\n",
+ (long)(link_sta->debugfs_dir), link_dir_name,
+ link_sta->sta->debugfs_dir);
+ link_sta->debugfs_dir = NULL;
+ return;
+ }
+
DEBUGFS_ADD(addr);
} else {
if (WARN_ON(link_sta != &link_sta->sta->deflink))
--
2.42.0
next prev parent reply other threads:[~2026-03-12 17:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 16:59 [PATCH wireless-next v2 00/28] iwlwifi + mac80211 stability greearb
2026-03-12 16:59 ` [PATCH wireless-next v2 01/28] wifi: iwlwifi: mld: Check for NULL before lookup greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 02/28] wifi: iwlwifi: mld: Add check for null vif in stats callback greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 03/28] wifi: wireless: Check debugfs create return values greearb
2026-03-12 17:00 ` greearb [this message]
2026-03-12 17:00 ` [PATCH wireless-next v2 05/28] wifi: mac80211: do not fail taking sta to lower state greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 06/28] wifi: mac80211: Mark sta as uploaded if single transition succeeds greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 07/28] wifi: mac80211: Fix use-after-free of debugfs inodes greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 08/28] wifi: mac80211: Debugfs safety checks greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 09/28] wifi: mac80211: Use warn-on-once in drv_remove_chanctxt greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 10/28] wifi: mac80211: Ensure sta debugfs is not double-freed greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 11/28] wifi: iwlwifi: mld: Fix stale reference in fw_id_to_link_sta greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 12/28] wifi: iwlwifi: mld: Improve logging in error cases greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 13/28] wifi: iwlwifi: mld: Remove warning about BAID greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 14/28] wifi: mac80211: Add dmesg log regarding warn-on in drv-stop greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 15/28] wifi: iwlwifi: mld: Fix use-after-free of bss_conf greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 16/28] wifi: iwlwifi: mld: Check for null in iwl_mld_wait_sta_txqs_empty greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 17/28] wifi: iwlwifi: mld: use warn-on-once in error path greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 18/28] wifi: iwlwifi: mld: Use warn-on-once in emlsr exit logic greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 19/28] wifi: iwlwifi: mld: Improve error message in rx path greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 20/28] wifi: iwlwifi: mld: Improve logging message greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 21/28] wifi: iwlwifi: mld: Protect from null mld_sta greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 22/28] wifi: mac80211: Add force-cleanup call to driver greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 23/28] wifi: iwlwifi: mld: Support force-cleanup op greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 24/28] wifi: iwlwifi: mld: Fix NPE in flush logic greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 25/28] wifi: iwlwifi: mld: Fix bad return address in tx code greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 26/28] wifi: mac80211: Ensure link work-items are only initialized once greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 27/28] wifi: iwlwifi: mld: Convert to WARN_ONCE in link removal path greearb
2026-03-12 17:00 ` [PATCH wireless-next v2 28/28] wifi: mac80211: Decrease WARN spam greearb
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=20260312170026.285494-5-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=linux-wireless@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox