Skip to content

Commit 1588559

Browse files
jmberg-intelksacilotto
authored andcommitted
wext: fix NULL-ptr-dereference with cfg80211's lack of commit()
BugLink: https://bugs.launchpad.net/bugs/1916056 commit 5122565 upstream. Since cfg80211 doesn't implement commit, we never really cared about that code there (and it's configured out w/o CONFIG_WIRELESS_EXT). After all, since it has no commit, it shouldn't return -EIWCOMMIT to indicate commit is needed. However, EIWCOMMIT is actually an alias for EINPROGRESS, which _can_ happen if e.g. we try to change the frequency but we're already in the process of connecting to some network, and drivers could return that value (or even cfg80211 itself might). This then causes us to crash because dev->wireless_handlers is NULL but we try to check dev->wireless_handlers->standard[0]. Fix this by also checking dev->wireless_handlers. Also simplify the code a little bit. Cc: [email protected] Reported-by: [email protected] Reported-by: [email protected] Link: https://lore.kernel.org/r/20210121171621.2076e4a37d5a.I5d9c72220fe7bb133fb718751da0180a57ecba4e@changeid Signed-off-by: Johannes Berg <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent ffe23b3 commit 1588559

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/wireless/wext-core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,9 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
896896
int call_commit_handler(struct net_device *dev)
897897
{
898898
#ifdef CONFIG_WIRELESS_EXT
899-
if ((netif_running(dev)) &&
900-
(dev->wireless_handlers->standard[0] != NULL))
899+
if (netif_running(dev) &&
900+
dev->wireless_handlers &&
901+
dev->wireless_handlers->standard[0])
901902
/* Call the commit handler on the driver */
902903
return dev->wireless_handlers->standard[0](dev, NULL,
903904
NULL, NULL);

0 commit comments

Comments
 (0)