Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp250934rwl; Thu, 6 Apr 2023 18:32:49 -0700 (PDT) X-Google-Smtp-Source: AKy350bvs6CSMLWghQeFnBeOHbD8owpRioByHqAD/0nSLafLtGCLDrri31sQzmHS7Tl6e6j+l931 X-Received: by 2002:a17:907:3e17:b0:87f:5d0a:c610 with SMTP id hp23-20020a1709073e1700b0087f5d0ac610mr772801ejc.32.1680831169639; Thu, 06 Apr 2023 18:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680831169; cv=none; d=google.com; s=arc-20160816; b=h2+vIiHJar3AsQDA4qRRuqdGD7cGovnuXFarca4uML6AR66HPzJS1ivQtTRDIpnK5g fxhi8JP0LmTcRuWY+JPQW/Q3QhvRJwTOhesRkadmflVf+KycBlal2KexSHFbCLaD0dx5 aV4kA24nOifOYO5GrfPVCH0PvMK4W9ST0sEztD3zZDfdr60YL6CFVFybm4Y7FjKFgOiQ /KK171H1J9tXzg6Me9Q+VzKvYMMAXFq6jbwA+71tidygwiFLJTrxP/Ken9sOUi8l+y+k iLS3pX+PDLZ4xree+tp2wn+gQnTmlSDioK5mZjGb3TJhFefFUQxUUjieYvDq0DMVQuH0 /DWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=5AhNgaaGO9qearGRujtpX7xQL4VfZn3Iowog8982fMM=; b=yVjkP9GQpxsGKCezE0PLJCVlbsQcp/I+Y7VOgH4x3jCSkO0ipEC9XSPdRaamyPB6eT C2ph2zkluigskqvPkjFAOeTcsxj2XpaJ/600ZIRD4o55jlvgnKlSnL1+fTlHu2nuRub6 za9xtHx22zdkb8Xz3nrwuUudiMXLz3ii+H5DVIw3RJCve5daZ14XT0rIth8hASZN4dd4 XopiAZS8T+uxoCAZ+y/LWMNShut12exUZcFJD1JFw7EaybaBLxj4J1hZejtoo7+DVJjV NE10nTMVGrbV6OPylmLr1eVw5nUC8t1xKSIJAamOAfURyHE85qxJDayztSuT4AFt84/7 GToA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=bCS34wZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020aa7c984000000b004fc9c1d4360si2205249edt.529.2023.04.06.18.32.17; Thu, 06 Apr 2023 18:32:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=bCS34wZI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239255AbjDGB1m (ORCPT + 99 others); Thu, 6 Apr 2023 21:27:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239196AbjDGB1j (ORCPT ); Thu, 6 Apr 2023 21:27:39 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 660AA93EA; Thu, 6 Apr 2023 18:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=5AhNg aaGO9qearGRujtpX7xQL4VfZn3Iowog8982fMM=; b=bCS34wZIBAD8MAjFqN7DX EL7vvjz6coEZXQPwg7r+urbC/k71DQN0UbR86fxbKcfRkSQ8aZPGSgXpIvomtiWn MjZ1rqZtetkfxjt1Zc08I4OAi4tA4Mw+ZkLKJOSliq4C6BKe/iwZora24+1hG4oD KpgcNOOcgeh7Ou3sme2kdA= Received: from localhost.localdomain (unknown [119.3.119.19]) by zwqz-smtp-mta-g2-0 (Coremail) with SMTP id _____wC31LFQcS9klZYEAw--.46479S2; Fri, 07 Apr 2023 09:26:41 +0800 (CST) From: Chen Aotian To: alex.aring@gmail.com Cc: stefan@datenfreihafen.org, miquel.raynal@bootlin.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Aotian Subject: [PATCH] ieee802154: hwsim: Fix possible memory leaks Date: Fri, 7 Apr 2023 09:26:26 +0800 Message-Id: <20230407012626.45500-1-chenaotian2@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wC31LFQcS9klZYEAw--.46479S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7CFWUCFWDGF48ur1rXw1xuFg_yoW8JFy8pF Wjv3sxtF48tr18W3yDGw4kAa4SyayrWry8ur1fKa93ZF1IqrW09rnrGF1ayr4YyrWDC3Wf AF4qqr1avrn8CrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07joKZJUUUUU= X-Originating-IP: [119.3.119.19] X-CM-SenderInfo: xfkh0tprwlt0qs6rljoofrz/1tbiRRRKwGDuzUsVOAAAs+ X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After replacing e->info, it is necessary to free the old einfo. Signed-off-by: Chen Aotian --- 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 8445c2189..6e7e10b17 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -685,7 +685,7 @@ static int hwsim_del_edge_nl(struct sk_buff *msg, struct genl_info *info) static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info) { struct nlattr *edge_attrs[MAC802154_HWSIM_EDGE_ATTR_MAX + 1]; - struct hwsim_edge_info *einfo; + struct hwsim_edge_info *einfo, *einfo_old; struct hwsim_phy *phy_v0; struct hwsim_edge *e; u32 v0, v1; @@ -723,8 +723,10 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info) list_for_each_entry_rcu(e, &phy_v0->edges, list) { if (e->endpoint->idx == v1) { einfo->lqi = lqi; + einfo_old = rcu_dereference(e->info); rcu_assign_pointer(e->info, einfo); rcu_read_unlock(); + kfree_rcu(einfo_old, rcu); mutex_unlock(&hwsim_phys_lock); return 0; } -- 2.25.1