Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758251AbcDEOXt (ORCPT ); Tue, 5 Apr 2016 10:23:49 -0400 Received: from mail-qg0-f67.google.com ([209.85.192.67]:36033 "EHLO mail-qg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753136AbcDEOXr (ORCPT ); Tue, 5 Apr 2016 10:23:47 -0400 From: Bastien Philbert To: herbert@gondor.apana.org.au Cc: davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ipsec: Fix error handling in the function xfrm6_get_addr Date: Tue, 5 Apr 2016 10:23:39 -0400 Message-Id: <1459866219-19195-1-git-send-email-bastienphilbert@gmail.com> X-Mailer: git-send-email 2.5.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 999 Lines: 29 This fixes the error handling in the function xfrm_get_addr by checking if the call to ipv6_dev_get_saddr has failed and if so return -EADDRNOTAVAIL to signal to the caller of xfrm6_get_addr that the call has failed the error should be handled by the caller while also freeing the dst_entry structure pointer in use by this Signed-off-by: Bastien Philbert --- net/ipv6/xfrm6_policy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index c074771..759473e 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -64,7 +64,10 @@ static int xfrm6_get_saddr(struct net *net, int oif, return -EHOSTUNREACH; dev = ip6_dst_idev(dst)->dev; - ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6); + if (ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6)) { + dst_release(dst); + return -EADDRNOTAVAIL; + } dst_release(dst); return 0; } -- 2.5.0