Skip to contentSkip to conversation

mt76: mt7915: fix possible deadlock in mt7915_stop

bug report Dan Carpenter 1 participant 1 message May 20, 2020 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

Hello Ryder Lee,

The patch 57b9df6fa5f5: "mt76: mt7915: fix possible deadlock in mt7915_stop" from May 12, 2020, leads to the following static checker warning:

drivers/net/wireless/mediatek/mt76/mt7915/init.c:595 mt7915_register_ext_phy()
error: we previously assumed 'phy' could be null (see line 592)

drivers/net/wireless/mediatek/mt76/mt7615/init.c:371 mt7615_register_ext_phy()
error: we previously assumed 'phy' could be null (see line 368)

drivers/net/wireless/mediatek/mt76/mt7915/init.c
589 if (test_bit(MT76_STATE_RUNNING, &dev->mphy.state))
590 return -EINVAL;
591
592 if (phy)

                    ^^^
   593                  return 0;
   594  
   595          INIT_DELAYED_WORK(&phy->mac_work, mt7915_mac_work);
                                  ^^^^^^^^^^^^^^

This will Oops.

   596          mt7915_cap_dbdc_enable(dev);
   597          mphy = mt76_alloc_phy(&dev->mt76, sizeof(*phy), &mt7915_ops);
   598          if (!mphy)
   599                  return -ENOMEM;
   600  
   601          phy = mphy->priv;
                ^^^^^^^^^^^^^^^^

phy is set here again.

   602          phy->dev = dev;
   603          phy->mt76 = mphy;
   604          phy->chainmask = dev->chainmask & ~dev->phy.chainmask;
   605          mphy->antenna_mask = BIT(hweight8(phy->chainmask)) - 1;
   606          mt7915_init_wiphy(mphy->hw);

See also:
drivers/net/wireless/mediatek/mt76/mt7615/init.c:371 mt7615_register_ext_phy() error: we previously assumed 'phy' could be null (see line 368)

regards,
dan carpenter