From patchwork Tue Aug 30 13:46:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 112309 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 43FF8B8013 for ; Tue, 30 Aug 2011 23:49:10 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753892Ab1H3NtF (ORCPT ); Tue, 30 Aug 2011 09:49:05 -0400 Received: from mail-qy0-f181.google.com ([209.85.216.181]:46529 "EHLO mail-qy0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754109Ab1H3NtC (ORCPT ); Tue, 30 Aug 2011 09:49:02 -0400 Received: by qyk34 with SMTP id 34so4493435qyk.19 for ; Tue, 30 Aug 2011 06:49:01 -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=mcx2TI4jDjVtfA7yndiJ0+36+h/S6dNW6eWhWg84zxo=; b=a9jFcIk/v8wZlURPg8rIeO6PRQABkoad+ctzniUx8gq3Y3G03r6ZCGbShJVM8rcieO BvtM9HtdMf2WKR2R5V7AvKDHMUQ5VRUegCL83oyvnNxigV0zq5eTVWxlLFy2cUaIAMpt OPZmQokyfBFYBkcjzuhJ7ft8rnOyL5VmERt2o= Received: by 10.142.212.6 with SMTP id k6mr1777755wfg.96.1314712140739; Tue, 30 Aug 2011 06:49:00 -0700 (PDT) Received: from shale.localdomain ([41.139.221.94]) by mx.google.com with ESMTPS id z12sm2830284wfn.11.2011.08.30.06.48.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 30 Aug 2011 06:49:00 -0700 (PDT) Date: Tue, 30 Aug 2011 16:46:40 +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 2/3 -next] 6LoWPAN: use the _safe version of list_for_each Message-ID: <20110830134640.GI3705@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 When we kfree(entry) that causes a use-after-free bug so we have to use list_for_each_entry_safe() safe here. Signed-off-by: Dan Carpenter --- Curly parens are not needed here, but kernel style is to use them for multi-line indent blocks. -- 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 cf304cc..5dc0489 100644 --- a/net/ieee802154/6lowpan.c +++ b/net/ieee802154/6lowpan.c @@ -813,15 +813,17 @@ static void lowpan_dellink(struct net_device *dev, struct list_head *head) struct lowpan_dev_info *lowpan_dev = lowpan_dev_info(dev); struct net_device *real_dev = lowpan_dev->real_dev; struct lowpan_dev_record *entry; + struct lowpan_dev_record *tmp; ASSERT_RTNL(); mutex_lock(&lowpan_dev_info(dev)->dev_list_mtx); - list_for_each_entry(entry, &lowpan_devices, list) + list_for_each_entry_safe(entry, tmp, &lowpan_devices, list) { if (entry->ldev == dev) { list_del(&entry->list); kfree(entry); } + } mutex_unlock(&lowpan_dev_info(dev)->dev_list_mtx); mutex_destroy(&lowpan_dev_info(dev)->dev_list_mtx);