[qca-nss-drv] NSS mirror stats fix when active instance is 0.
After deleting the single mirror instance, the mirror active
instance count becomes 0. At that time, if somebody tries to print
the mirror stats, then vzalloc error will be shown because of the
vzalloc(0) call.
Change-Id: Ib2615974141c1f8039e0234f6ae77adb37ff5639
Signed-off-by: Manish Verma <maniverm@codeaurora.org>
diff --git a/nss_mirror_stats.c b/nss_mirror_stats.c
index 230e91b..574312b 100644
--- a/nss_mirror_stats.c
+++ b/nss_mirror_stats.c
@@ -91,8 +91,13 @@
struct net_device *dev;
struct nss_mirror_stats_debug_instance *mirror_shadow_stats;
uint32_t id, mirror_active_instances = atomic_read(&nss_mirror_num_instances);
+ char *lbuf;
- char *lbuf = vzalloc(size_al);
+ if (!mirror_active_instances) {
+ return 0;
+ }
+
+ lbuf = vzalloc(size_al);
if (unlikely(!lbuf)) {
nss_warning("Could not allocate memory for local statistics buffer");
return 0;