[ath:ath-next 6/34] net/wireless/nl80211.c:20114 nl80211_pre_doit() error: 'wdev' dereferencing possible ERR_PTR()
Johannes Berg
johannes at sipsolutions.net
Thu Oct 15 02:48:59 PDT 2026
On Thu, 2026-10-15 at 12:40 +0300, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/ath/ath.git ath-next
> head: cd026e68fdbf88b9cc522b76c7a9d92c9a41f709
> commit: 13c20e8be3278e54f4758941998a3ee746644d8d [6/34] wifi: nl80211: prepare for unlocked wdev-only ops
> config: sparc-randconfig-r2200-20261013 (https://download.01.org/0day-ci/archive/20261014/202610140243.w1Zrwq4k-lkp@intel.com/config)
> compiler: sparc64-linux-gcc (GCC) 14.3.0
> smatch: v0.5.0-9187-g5189e3fb
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> > Reported-by: kernel test robot <lkp at intel.com>
> > Reported-by: Dan Carpenter <error27 at gmail.com>
> > Closes: https://lore.kernel.org/r/202610140243.w1Zrwq4k-lkp@intel.com/
>
> New smatch warnings:
> net/wireless/nl80211.c:20114 nl80211_pre_doit() error: 'wdev' dereferencing possible ERR_PTR()
It's a bit needlessly worried, because:
> 13c20e8be3278e Johannes Berg 2026-10-09 19979 wdev_ref = nl80211_need_wdev_ref(internal_flags);
This is
static bool nl80211_need_wdev_ref(u32 internal_flags)
{
return !(internal_flags & NL80211_FLAG_NEED_RTNL) &&
internal_flags & NL80211_FLAG_NO_WIPHY_MTX;
}
so NL80211_FLAG_NO_WIPHY_MTX must be set
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20029 if (rdev && !(internal_flags & NL80211_FLAG_NO_WIPHY_MTX)) {
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20030 if (need_rtnl) {
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20031 wiphy_lock(&rdev->wiphy);
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20032 } else {
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20033 /* without rtnl, things may have changed since lookup */
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20034 wdev = nl80211_lock_and_recheck(rdev, netns, wdev_id);
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20035 if (IS_ERR(wdev)) {
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20036 err = PTR_ERR(wdev);
> 8e3d9039d280c6 Johannes Berg 2026-10-06 20037 goto out;
>
> Smatch is worried about this goto.
while we can only get to that goto when it's not set.
I guess we can still set wdev to NULL here to avoid the dependency and
potential future bugs.
johannes
More information about the ath12k
mailing list