]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix memleak in e100 driver
authorAndrew Morton <akpm@digeo.com>
Sun, 16 Mar 2003 15:22:39 +0000 (07:22 -0800)
committerDave Jones <davej@codemonkey.org.uk>
Sun, 16 Mar 2003 15:22:39 +0000 (07:22 -0800)
Patch from Oleg Drokin <green@linuxhacker.ru>

    There is a memleak in e100 driver from intel, both in 2.4 and 2.5
    e100_ethtool_gstrings does not free "strings" variable if it cannot
    copy it to userspace.

drivers/net/e100/e100_main.c

index 523e83f771dad14a7c08ea788136be3527572c7c..1f1f70caca21af0ef47e88e3a9a2325643bba372 100644 (file)
@@ -3784,11 +3784,15 @@ static int e100_ethtool_gstrings(struct net_device *dev, struct ifreq *ifr)
                return -EOPNOTSUPP;
        }
 
-       if (copy_to_user(ifr->ifr_data, &info, sizeof (info)))
+       if (copy_to_user(ifr->ifr_data, &info, sizeof (info))) {
+               kfree(strings);
                return -EFAULT;
+       }
 
-       if (copy_to_user(usr_strings, strings, info.len * ETH_GSTRING_LEN))
+       if (copy_to_user(usr_strings, strings, info.len * ETH_GSTRING_LEN)) {
+               kfree(strings);
                return -EFAULT;
+       }
 
        kfree(strings);
        return 0;