[][mt76-vendor: fix coverity errors]
[Description]
Fix some coverity errors for mt76-vendor.
[Release-log]
N/A
Change-Id: Iccc74680df03762d1997a6684a109227aed2b27b
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5059083
diff --git a/feed/mt76-vendor/src/amnt.c b/feed/mt76-vendor/src/amnt.c
index 55eb071..653e785 100644
--- a/feed/mt76-vendor/src/amnt.c
+++ b/feed/mt76-vendor/src/amnt.c
@@ -3,13 +3,13 @@
#include "mt76-vendor.h"
-static const struct nla_policy
+static struct nla_policy
amnt_ctrl_policy[NUM_MTK_VENDOR_ATTRS_AMNT_CTRL] = {
[MTK_VENDOR_ATTR_AMNT_CTRL_SET] = {.type = NLA_NESTED },
[MTK_VENDOR_ATTR_AMNT_CTRL_DUMP] = { .type = NLA_NESTED },
};
-static const struct nla_policy
+static struct nla_policy
amnt_dump_policy[NUM_MTK_VENDOR_ATTRS_AMNT_DUMP] = {
[MTK_VENDOR_ATTR_AMNT_DUMP_INDEX] = {.type = NLA_U8 },
[MTK_VENDOR_ATTR_AMNT_DUMP_LEN] = { .type = NLA_U8 },
@@ -30,14 +30,23 @@
return -EINVAL;
tb1 = nla_nest_start(msg, MTK_VENDOR_ATTR_AMNT_CTRL_SET | NLA_F_NESTED);
+ if (!tb1)
+ return -ENOMEM;
+
nla_put_u8(msg, MTK_VENDOR_ATTR_AMNT_SET_INDEX, idx);
tb2 = nla_nest_start(msg, MTK_VENDOR_ATTR_AMNT_SET_MACADDR | NLA_F_NESTED);
+ if (!tb2) {
+ nla_nest_end(msg, tb1);
+ return -ENOMEM;
+ }
+
for (i = 0; i < ETH_ALEN; i++)
nla_put_u8(msg, i, a[i]);
nla_nest_end(msg, tb2);
nla_nest_end(msg, tb1);
+
return 0;
}
@@ -165,4 +174,4 @@
unl_free(&unl);
return ret;
-}
\ No newline at end of file
+}