[AF_KEY]: Fix skb leak on pfkey_send_migrate() error
authorPatrick McHardy <kaber@trash.net>
Mon, 21 Jan 2008 01:24:29 +0000 (17:24 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Jan 2008 04:31:45 +0000 (20:31 -0800)
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/key/af_key.c

index 26d5e63c4cc5d946c61e5bdf6702dacb8d32640a..76dcd882f87b97e3c5195fe96e9e0a9eb5178c78 100644 (file)
@@ -3593,27 +3593,29 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
                /* old ipsecrequest */
                int mode = pfkey_mode_from_xfrm(mp->mode);
                if (mode < 0)
-                       return -EINVAL;
+                       goto err;
                if (set_ipsecrequest(skb, mp->proto, mode,
                                     (mp->reqid ?  IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
                                     mp->reqid, mp->old_family,
-                                    &mp->old_saddr, &mp->old_daddr) < 0) {
-                       return -EINVAL;
-               }
+                                    &mp->old_saddr, &mp->old_daddr) < 0)
+                       goto err;
 
                /* new ipsecrequest */
                if (set_ipsecrequest(skb, mp->proto, mode,
                                     (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
                                     mp->reqid, mp->new_family,
-                                    &mp->new_saddr, &mp->new_daddr) < 0) {
-                       return -EINVAL;
-               }
+                                    &mp->new_saddr, &mp->new_daddr) < 0)
+                       goto err;
        }
 
        /* broadcast migrate message to sockets */
        pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL);
 
        return 0;
+
+err:
+       kfree_skb(skb);
+       return -EINVAL;
 }
 #else
 static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,