]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
mt76: fix a possible NULL pointer dereference in mt76_testmode_dump
authorLorenzo Bianconi <lorenzo@kernel.org>
Fri, 21 Aug 2020 10:52:15 +0000 (12:52 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 24 Sep 2020 16:10:15 +0000 (18:10 +0200)
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>
drivers/net/wireless/mediatek/mt76/testmode.c

index 75bb02cdfdae4b9c1ba552c62813559d837bbf35..5bd6ac1ba3b5b0cb8567e223df14900529bac33a 100644 (file)
@@ -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;
        }