wifi: wext-core: Fix -Wstringop-overflow warning in ioctl_standard_iw_point()
[platform/kernel/linux-starfive.git] / net / wireless / wext-core.c
index a125fd1..a161c64 100644 (file)
@@ -815,6 +815,12 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
                }
        }
 
+       /* Sanity-check to ensure we never end up _allocating_ zero
+        * bytes of data for extra.
+        */
+       if (extra_size <= 0)
+               return -EFAULT;
+
        /* kzalloc() ensures NULL-termination for essid_compat. */
        extra = kzalloc(extra_size, GFP_KERNEL);
        if (!extra)