From patchwork Sun Aug 12 20:24:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 10563717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1AED15A6 for ; Sun, 12 Aug 2018 20:25:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC63B29292 for ; Sun, 12 Aug 2018 20:25:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE30629296; Sun, 12 Aug 2018 20:25:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20C2529292 for ; Sun, 12 Aug 2018 20:25:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728121AbeHLXEU (ORCPT ); Sun, 12 Aug 2018 19:04:20 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:52723 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728112AbeHLXEU (ORCPT ); Sun, 12 Aug 2018 19:04:20 -0400 Received: by mail-it0-f65.google.com with SMTP id d9-v6so9822071itf.2 for ; Sun, 12 Aug 2018 13:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=EuxOagbufZpaczbwGAs9gpCfhV8T7uXfLBHrwvuM5AQ=; b=MYWwe91VolNYRAL5k2HIIipiLTpPmrj0Cay8ZQxl9hTOHzh0iJmLbrCuVlZ6B75UKB fxVDQQil9aKN5Uos/uCLSU3M7k6z0YCJkh6UyQ6QhvuW+thnN/VuqGFWclGoUOV6fImR m6PQW5F6NJtgbLJch1RO/uIG0d3o33wjksvnRFlJQvNY0wsUCsK9GI7JaVblFZchEu83 sYoogdFMSQJ4Y3Eq8aExnSp0UFQDtJFMfov2uNhDIQSTn64rOUto1yA/9Azrt9Qnia+T X1bd1xDSF/qkDq1nazGNJEDi5ZPxOkyarN5EAMZM6+wOhMZxyZMClTIjgZ0F3TX2xeWN 58NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EuxOagbufZpaczbwGAs9gpCfhV8T7uXfLBHrwvuM5AQ=; b=t/T4LUySxHvvZEi+AUgh5eiSrPHj2XhSxgramTfZkSregJQcVxpFrLGHjAIhSXHduL 2ZJoncg+u9oTmpMYk1iFxJXUor+l6UR7G/DeRiRpV8ZubHmcyB9R8KZvl5ggHjg8yvEr Ol1q/2z4LbVR7t4COJyiNpVXS5TE3SgcVVujb3jrh3Re/+Y3BJVotSgC6FjVJ2hG3ROj IsL61cn6iw5rYLqrCxISRBKkIc82xpeqVoDsvtegV5dBQR1uJZ/Olc30Pzag0r1rpy+u K+PRI7XEnrj5HmmKPLAa6Mn3r3iJLiGwT/+Gi4X74TUKCbA8satdgZDqujcyEzmvxTgQ TBqg== X-Gm-Message-State: AOUpUlFLPLMRC6jMZIMfnIYjP3pJR9P1xpAZdBwSGLb7avvEvDND861W n14UBBZFfNzSr0k5uOe8az7kw1tZHnU= X-Google-Smtp-Source: AA+uWPyDWsTujDiyz01jNSy+sM68gzs+XJhaZRGpim2Bul/8BJQ0eHltst6Wm3xUUmcWHhCajiu0Lw== X-Received: by 2002:a24:dd88:: with SMTP id t130-v6mr8374438itf.129.1534105510566; Sun, 12 Aug 2018 13:25:10 -0700 (PDT) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id v3-v6sm4902806ita.6.2018.08.12.13.25.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Aug 2018 13:25:09 -0700 (PDT) From: Alexander Aring To: netdev@vger.kernel.org Cc: linux-wpan@vger.kernel.org, kernel@mojatatu.com, Alexander Aring , Stefan Schmidt Subject: [PATCH net-next] ieee802154: hwsim: using right kind of iteration Date: Sun, 12 Aug 2018 16:24:56 -0400 Message-Id: <20180812202456.22317-1-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes the error path to unsubscribe all other phy's from current phy. The actually code using a wrong kind of list iteration may copied from the case to unsubscribe the current phy from all other phy's. Cc: Stefan Schmidt Reported-by: Dan Carpenter Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") Signed-off-by: Alexander Aring --- drivers/net/ieee802154/mac802154_hwsim.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index 07a493dea11e..bf70ab892e69 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -735,10 +735,12 @@ static int hwsim_subscribe_all_others(struct hwsim_phy *phy) return 0; me_fail: - list_for_each_entry(phy, &hwsim_phys, list) { + rcu_read_lock(); + list_for_each_entry_rcu(e, &phy->edges, list) { list_del_rcu(&e->list); hwsim_free_edge(e); } + rcu_read_unlock(); sub_fail: hwsim_edge_unsubscribe_me(phy); return -ENOMEM;