]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: vt6655: fix overly large stack usage
authorArnd Bergmann <arnd@arndb.de>
Fri, 5 May 2017 19:47:23 +0000 (21:47 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 11 Nov 2017 13:34:51 +0000 (13:34 +0000)
We get a warning for the large stack usage in some configurations:

drivers/staging/vt6655/device_main.c: In function 'device_ioctl':
drivers/staging/vt6655/device_main.c:2974:1: warning: the frame size of 1304 bytes is larger than 1024 bytes [-Wframe-larger-than=]

This is addressed in linux-3.19 with commit 67013f2c0e58 ("staging: vt6655:
mac80211 conversion add main mac80211 functions"), which obsoletes the
device_ioctl() function, but as that does not apply to stable kernels,
this picks an easier way out by using dynamic allocation.

The driver was merged in 2.6.31, and the fix applies to all versions
before 3.19.

Fixes: 5449c685a4b3 ("Staging: Add pristine upstream vt6655 driver sources")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/staging/vt6655/device_main.c

index 077c5062b91fbeece8571a9f2d7098a44df3a9a5..5765bb96e9feea3567e59e5b15c5b1725a8946de 100644 (file)
@@ -3387,9 +3387,12 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
 
        case SIOCGIWAPLIST:
            {
-            char buffer[IW_MAX_AP * (sizeof(struct sockaddr) + sizeof(struct iw_quality))];
+               char *buffer = kzalloc(IW_MAX_AP * (sizeof(struct sockaddr) +
+                                      sizeof(struct iw_quality)), GFP_KERNEL);
 
-                   if (wrq->u.data.pointer) {
+               if (!buffer) {
+                       rc = -ENOMEM;
+               } else if (wrq->u.data.pointer) {
                        rc = iwctl_giwaplist(dev, NULL, &(wrq->u.data), buffer);
                        if (rc == 0) {
                     if (copy_to_user(wrq->u.data.pointer,
@@ -3399,6 +3402,7 @@ static int  device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
                                    rc = -EFAULT;
                        }
             }
+               kfree(buffer);
         }
                break;