Skip to content

Commit

Permalink
cfg80211: check dev_set_name() return value
Browse files Browse the repository at this point in the history
syzbot reported a warning from rfkill_alloc(), and after a while
I think that the reason is that it was doing fault injection and
the dev_set_name() failed, leaving the name NULL, and we didn't
check the return value and got to rfkill_alloc() with a NULL name.
Since we really don't want a NULL name, we ought to check the
return value.

Fixes: fb28ad3 ("net: struct device - replace bus_id with dev_name(), dev_set_name()")
Reported-by: [email protected]
Signed-off-by: Johannes Berg <[email protected]>
  • Loading branch information
jmberg-intel committed Jan 15, 2018
1 parent 51a1aaa commit 59b179b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion net/wireless/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,20 @@ struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
if (rv)
goto use_default_name;
} else {
int rv;

use_default_name:
/* NOTE: This is *probably* safe w/out holding rtnl because of
* the restrictions on phy names. Probably this call could
* fail if some other part of the kernel (re)named a device
* phyX. But, might should add some locking and check return
* value, and use a different name if this one exists?
*/
dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
rv = dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
if (rv < 0) {
kfree(rdev);
return NULL;
}
}

INIT_LIST_HEAD(&rdev->wiphy.wdev_list);
Expand Down

0 comments on commit 59b179b

Please sign in to comment.