diff options
author | Lorenzo Bianconi <lorenzo@kernel.org> | 2020-08-21 12:52:15 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2020-09-24 18:10:15 +0200 |
commit | ce8463a726a5669b200a1c2c17f95bc1394cc6bf (patch) | |
tree | aa3f75af4759ba960a62a06de9e8cb97300272d8 /drivers/net/wireless/mediatek/mt76/testmode.c | |
parent | a081de174d11b12db9a94eb748041c2732f14c10 (diff) | |
download | linux-stable-ce8463a726a5669b200a1c2c17f95bc1394cc6bf.tar.gz linux-stable-ce8463a726a5669b200a1c2c17f95bc1394cc6bf.tar.bz2 linux-stable-ce8463a726a5669b200a1c2c17f95bc1394cc6bf.zip |
mt76: fix a possible NULL pointer dereference in mt76_testmode_dump
Fix a possible NULL pointer dereference in mt76_testmode_dump() since
nla_nest_start returns NULL in case of error
Fixes: f0efa8621550e ("mt76: add API for testmode support")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/testmode.c')
-rw-r--r-- | drivers/net/wireless/mediatek/mt76/testmode.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/testmode.c b/drivers/net/wireless/mediatek/mt76/testmode.c index 75bb02cdfdae..5bd6ac1ba3b5 100644 --- a/drivers/net/wireless/mediatek/mt76/testmode.c +++ b/drivers/net/wireless/mediatek/mt76/testmode.c @@ -442,9 +442,13 @@ int mt76_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *msg, mutex_lock(&dev->mutex); if (tb[MT76_TM_ATTR_STATS]) { + err = -EINVAL; + a = nla_nest_start(msg, MT76_TM_ATTR_STATS); - err = mt76_testmode_dump_stats(dev, msg); - nla_nest_end(msg, a); + if (a) { + err = mt76_testmode_dump_stats(dev, msg); + nla_nest_end(msg, a); + } goto out; } |