From patchwork Tue Aug 30 13:51:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 112313 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 88B15B6FA6 for ; Tue, 30 Aug 2011 23:53:38 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754178Ab1H3Nxd (ORCPT ); Tue, 30 Aug 2011 09:53:33 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:57023 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753069Ab1H3Nxb (ORCPT ); Tue, 30 Aug 2011 09:53:31 -0400 Received: by wyg24 with SMTP id 24so4925212wyg.19 for ; Tue, 30 Aug 2011 06:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=MRp9jFQjAXTA5mY15NbERP3EdvLTffo2cRptT0QyVAA=; b=R6wDbJxoW68kZbVHWDkmet28NW7ZT67gakQHEYoA1bXrX2GZJqyPODzpab2scrs6AS TZs2nAGJHgkgM+MPmtzJOlerHU5WJ/eXzQiEQntzLxBSHzHKnQsJeeHTg366puqm3dKW 7sdXWEaE0tFhilKdFVBQpoZJmId8YPNGud0Cg= Received: by 10.216.9.225 with SMTP id 75mr819472wet.7.1314712410120; Tue, 30 Aug 2011 06:53:30 -0700 (PDT) Received: from shale.localdomain ([212.49.88.34]) by mx.google.com with ESMTPS id y61sm3635426wec.6.2011.08.30.06.53.26 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 06:53:29 -0700 (PDT) Date: Tue, 30 Aug 2011 16:51:09 +0300 From: Dan Carpenter To: Alexander Smirnov Cc: Dmitry Eremin-Solenikov , Sergey Lapin , "David S. Miller" , "open list:IEEE 802.15.4 SUB..." , "open list:NETWORKING [GENERAL]" , kernel-janitors@vger.kernel.org Subject: [patch 3/3 -next] 6LoWPAN: call dev_put() on error in lowpan_newlink() Message-ID: <20110830135109.GJ3705@shale.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We should release the dev_hold() on error before returning here. Signed-off-by: Dan Carpenter --- All three of these patches were compile tested only, but this is the one I'm not very certain of. I've obviously tried to get it right, but please review it carefully. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c index 5dc0489..f0d1536 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -793,8 +793,11 @@ static int lowpan_newlink(struct net *src_net, struct net_device *dev, mutex_init(&lowpan_dev_info(dev)->dev_list_mtx); entry = kzalloc(sizeof(struct lowpan_dev_record), GFP_KERNEL); - if (!entry) + if (!entry) { + dev_put(real_dev); + lowpan_dev_info(dev)->real_dev = NULL; return -ENOMEM; + } entry->ldev = dev;