[qca-nss-clients] Handle static analyzer warnings for mirror.
Change-Id: If48e0d6ac5ada939d952599650933112d8b4bd48
Signed-off-by: Manish Verma <maniverm@codeaurora.org>
diff --git a/mirror/nss_mirror.c b/mirror/nss_mirror.c
index b976a33..a11ce42 100644
--- a/mirror/nss_mirror.c
+++ b/mirror/nss_mirror.c
@@ -274,12 +274,14 @@
*/
static void nss_mirror_data_cb(struct net_device *netdev, struct sk_buff *skb, struct napi_struct *napi)
{
- if (skb && skb->data) {
- nss_mirror_info("Printing 64 bytes of data\n");
- print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1,
- skb->data, 64, 0);
+ if (!skb || !skb->data) {
+ return;
}
+ nss_mirror_info("Printing 64 bytes of data\n");
+ print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 1,
+ skb->data, 64, 0);
+
dev_hold(netdev);
/*
diff --git a/mirror/nss_mirror_ctl.c b/mirror/nss_mirror_ctl.c
index 9adb250..f026321 100644
--- a/mirror/nss_mirror_ctl.c
+++ b/mirror/nss_mirror_ctl.c
@@ -211,7 +211,7 @@
{
struct net_device *mirror_dev = NULL;
char *param, *value;
- uint32_t nexthop_if_num;
+ int32_t nexthop_if_num = -1;
uint8_t param_num = NSS_MIRROR_SET_NEXTHOP_PARAM_NUM;
do {
@@ -249,6 +249,17 @@
}
} while (--param_num);
+ if (!mirror_dev) {
+ nss_mirror_warn("Mirror device is NULL\n");
+ return -1;
+ }
+
+ if (nexthop_if_num < 0) {
+ nss_mirror_warn("Invalid nexthop interface number\n");
+ dev_put(mirror_dev);
+ return -1;
+ }
+
if (nss_mirror_set_nexthop(mirror_dev, nexthop_if_num)) {
nss_mirror_warn("Error in sending set nexthop config to mirror interface: %s\n", mirror_dev->name);
dev_put(mirror_dev);
@@ -389,7 +400,7 @@
struct nss_ctx_instance *nss_ctx;
struct net_device *dev, *mirror_dev = NULL;
nss_tx_status_t status;
- int32_t if_num, type = 0, mirror_if_num;
+ int32_t if_num = -1, type = 0, mirror_if_num = -1;
uint8_t param_num = NSS_MIRROR_ENABLE_INGRESS_PMC_NUM;
do {
@@ -439,6 +450,17 @@
}
} while (--param_num);
+ if (!mirror_dev) {
+ nss_mirror_warn("Mirror device is NULL\n");
+ return -1;
+ }
+
+ if ((if_num < 0) || (mirror_if_num < 0)) {
+ nss_mirror_warn("Invalid interface number\n");
+ dev_put(mirror_dev);
+ return -1;
+ }
+
/*
* Return if the mirror interface is in open state.
*/