From patchwork Sun Aug 8 13:34:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ZhangJieJing X-Patchwork-Id: 61210 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 50D7FB6EF3 for ; Sun, 8 Aug 2010 23:34:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754078Ab0HHNeQ (ORCPT ); Sun, 8 Aug 2010 09:34:16 -0400 Received: from mail-qw0-f46.google.com ([209.85.216.46]:44133 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753700Ab0HHNeQ (ORCPT ); Sun, 8 Aug 2010 09:34:16 -0400 Received: by qwh6 with SMTP id 6so6426559qwh.19 for ; Sun, 08 Aug 2010 06:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:cc:content-type; bh=ix5SKKBY8fHcEfKJoTGTSh5/Gi6c2qwYN2lXow84QP8=; b=vy8fIuYnk+x2xUBlw7SBRtuHs1QeJlpIXlrxUvqAtI2SnbB9QO7YulI76rCf4HbTsb vwND+F+zS4EdF8MVKVG3lEtD6pMBfB3Z0ONMAN49iLJeCVfjiMYzjKaFMpkQSwJ+bss9 vlneMcBw2Bkb+pkz0NydZ1NRLMT0z34nAsyhc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=GqUWXRZXGMDehwicb4vhZP1ZTqXvbPdc9wq0qKQyhGP0ePV+7uhMG4+lqbJchIcjI3 We8LB1HBNjziYYmMhXQwW4P5BjnrCLZajcjEAUwAtCF+Q1u9NgmuT/987+EMmDXWNSIv EceyiiPyt/qXmt7jcH0dA/bBEFrOzC9zWUf6M= MIME-Version: 1.0 Received: by 10.224.110.206 with SMTP id o14mr7651009qap.69.1281274452175; Sun, 08 Aug 2010 06:34:12 -0700 (PDT) Received: by 10.229.226.75 with HTTP; Sun, 8 Aug 2010 06:34:12 -0700 (PDT) Date: Sun, 8 Aug 2010 21:34:12 +0800 Message-ID: Subject: [PATCH] xfrm: fix a possible leak of dev reference count. From: Zhang JieJing To: netdev@vger.kernel.org Cc: Dan Carpenter , Zhang Jiejing Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org call dev_put(dev) on error path. Signed-off-by: JieJing.Zhang --- net/ipv4/xfrm4_policy.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) if (rt->peer) diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 1705476..d2a4873 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -81,8 +81,10 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, dev_hold(dev); xdst->u.rt.idev = in_dev_get(dev); - if (!xdst->u.rt.idev) + if (!xdst->u.rt.idev) { + dev_put(dev); return -ENODEV; + } xdst->u.rt.peer = rt->peer;