[XFRM]: Fix existence lookup in xfrm_state_find
Patrick McHardy [Fri, 22 Apr 2005 03:12:32 +0000 (20:12 -0700)]
Use 'daddr' instead of &tmpl->id.daddr, since the latter
might be zero.  Also, only perform the lookup when
tmpl->id.spi is non-zero.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>

net/xfrm/xfrm_state.c

index 1db59f1..d11747c 100644 (file)
@@ -357,8 +357,9 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
 
        x = best;
        if (!x && !error && !acquire_in_progress) {
-               x0 = afinfo->state_lookup(&tmpl->id.daddr, tmpl->id.spi, tmpl->id.proto);
-               if (x0 != NULL) {
+               if (tmpl->id.spi &&
+                   (x0 = afinfo->state_lookup(daddr, tmpl->id.spi,
+                                              tmpl->id.proto)) != NULL) {
                        xfrm_state_put(x0);
                        error = -EEXIST;
                        goto out;