]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
geoip: add missing kfree in error path
authorJan Engelhardt <jengelh@computergmbh.de>
Mon, 17 Mar 2008 13:11:26 +0000 (14:11 +0100)
committerJan Engelhardt <jengelh@computergmbh.de>
Sat, 22 Mar 2008 02:59:44 +0000 (03:59 +0100)
extensions/xt_geoip.c

index 866683826530e9ab0e119e77200e3a48dbacb36a..5e393a771f09729e0c12d521656b27695c322ece 100644 (file)
@@ -35,12 +35,16 @@ static struct geoip_info *add_node(struct geoip_info *memcpy)
 
        struct geoip_subnet *s;
 
-       if ((p == NULL) || (copy_from_user(p, memcpy, sizeof(struct geoip_info)) != 0))
+       if (p == NULL)
                return NULL;
+       if (copy_from_user(p, memcpy, sizeof(struct geoip_info)) != 0)
+               goto free_p;
 
        s = kmalloc(p->count * sizeof(struct geoip_subnet), GFP_KERNEL);
-       if ((s == NULL) || (copy_from_user(s, p->subnets, p->count * sizeof(struct geoip_subnet)) != 0))
-               return NULL;
+       if (s == NULL)
+               goto free_p;
+       if (copy_from_user(s, p->subnets, p->count * sizeof(struct geoip_subnet)) != 0)
+               goto free_s;
 
        spin_lock_bh(&geoip_lock);
 
@@ -54,6 +58,11 @@ static struct geoip_info *add_node(struct geoip_info *memcpy)
 
        spin_unlock_bh(&geoip_lock);
        return p;
+ free_s:
+       kfree(s);
+ free_p:
+       kfree(p);
+       return NULL;
 }
 
 static void remove_node(struct geoip_info *p)