Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1713106rwl; Fri, 7 Apr 2023 23:54:39 -0700 (PDT) X-Google-Smtp-Source: AKy350bYdc9KAvIX9sLtPGxtI/4mkoyJrZCf4kMwniQcxs8zqurE4ss2Fi/n/BZebz0bJRgPy9mJ X-Received: by 2002:a05:6a20:49a2:b0:d4:32bb:11bd with SMTP id fs34-20020a056a2049a200b000d432bb11bdmr4085720pzb.45.1680936879550; Fri, 07 Apr 2023 23:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680936879; cv=none; d=google.com; s=arc-20160816; b=bNamNQ/EENGcyXHBrcMvYSofawA6UhdXbRu/9UGwsS17z70XEd4BBNbGyhNzU8mxZ7 4Y1AXnK56lUjDzSYpPFIntK3DpGWMZ7sF+NtVfAi05DovMeWcFwipQzrWdsbrvkdHngk GeAOdMUvveZS0wIXXos6ahKm2O/6bn4Hsk/lrnprU75LNsvl8UUklo7BHfkINeIyYwlO T6CGE6qnnKPtfgITbeVHogDK4BRR3fEaWcdMWup1DfJmzGImk8a8vg3YS04kym1MpXoX oqdErTZRiRrZii6F3n62uSJTXTXd5xRb5VKgFgKgfo02FyWLpEkA0gAjzKUcfW2ofK7F eLMQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D47zQmPvODBH5tr4rjq2FYpqkSG5BmR5CICEGe/y1pM=; b=PGYbbeTodXPltJtVAtse8GyKfHvnr8zVAhIViYmiRty27fv5+cceNfHGRvWO0QaNlO hPjulnlSFd7/UhBEkPNxBgN2z6EOmOX0Hv+AG1fv7Ed3o9ePRpiCf9wNf59urj/nl3/5 P0k2NyvBYmknMacKqXbZnrK20qbnHyS1wSF5AC4mv5cNnsKuNpawEceSEaAeAJZiM3Lz qAuWrjjC6Kc/rME7q8Uc3QPdsnkm5A5hc5GHH5Inad4Q/Rq571mgTfsOpDEbx+Y6qOJT aLdVo+T/vEy+RR8sWsq4upfV3EpWGM684rpLWdEOUBIqe91cETDCazcrN7BAqQtL6glF JQYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b="mG4Bc/or"; 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 t15-20020a63f34f000000b004770fe95989si5456764pgj.496.2023.04.07.23.54.18; Fri, 07 Apr 2023 23:54:39 -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="mG4Bc/or"; 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 S229739AbjDHGps (ORCPT + 99 others); Sat, 8 Apr 2023 02:45:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjDHGpq (ORCPT ); Sat, 8 Apr 2023 02:45:46 -0400 Received: from m12.mail.163.com (m12.mail.163.com [220.181.12.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 564FF9030; Fri, 7 Apr 2023 23:45:43 -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: Content-Type; bh=D47zQmPvODBH5tr4rjq2FYpqkSG5BmR5CICEGe/y1pM=; b=mG4Bc/orqtPCIe0SajihSHXMh3uUk9IeT4UDL4ZGh1K45oyd+JtN/9fO28HVuL qp20ETAihgEI2qgvmjgCHNW/ViG0Uh3Oetb2E3Xo3EiKZYr4I+E6q/qOFs5ye8mW mzZr3qMDSuriGE2lcr4hyKgw30hmGPgdcXElpJKVyQ6gM= Received: from localhost.localdomain (unknown [106.39.149.90]) by zwqz-smtp-mta-g5-4 (Coremail) with SMTP id _____wCHarweDTFkTmiQAw--.53636S2; Sat, 08 Apr 2023 14:43:42 +0800 (CST) From: Chen Aotian To: aahringo@redhat.com, miquel.raynal@bootlin.com Cc: alex.aring@gmail.com, chenaotian2@163.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, stable@vger.kernel.org, stefan@datenfreihafen.org Subject: Re: [PATCH] ieee802154: hwsim: Fix possible memory leaks Date: Sat, 8 Apr 2023 14:43:31 +0800 Message-Id: <20230408064331.46176-1-chenaotian2@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-CM-TRANSID: _____wCHarweDTFkTmiQAw--.53636S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7KrWDJryrtFW8Aw43WF1DGFg_yoW8Ar15pF WjvasIkF48tr18WayDXw4rA34Sva1fWry8ur1fK3ZY9F12qrW8uF17G3WSvF4FyrZru3Wf ZF4qqr1avwn8CrDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U489NUUUUU= X-Originating-IP: [106.39.149.90] X-CM-SenderInfo: xfkh0tprwlt0qs6rljoofrz/xtbCggdLwGD-z8JIegAAsu 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 Fri, 7 Apr 2023 18:20:32 -0400 Alexander Aring wrote: > > On Fri, Apr 7, 2023 at 5:55 AM Chen Aotian wrote: > > > > After replacing e->info, it is necessary to free the old einfo. > > > > Fixes: f25da51fdc38 ("ieee802154: hwsim: add replacement for fakelb") > > 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); > > nitpick rcu_replace_pointer() can be used here.* Thank you for your suggestion, Alex. BTW, thanks for Miquèl's patient guidance too, I just started trying to submit patches to the kernel, I will do batter. Thanks, Chen