From nobody Thu Sep 18 23:34:43 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8501C43217 for ; Thu, 1 Dec 2022 15:16:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231172AbiLAPQd (ORCPT ); Thu, 1 Dec 2022 10:16:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiLAPQb (ORCPT ); Thu, 1 Dec 2022 10:16:31 -0500 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 714899953F; Thu, 1 Dec 2022 07:16:29 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 358CC1E80D27; Thu, 1 Dec 2022 23:12:26 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bGIo08odmUoF; Thu, 1 Dec 2022 23:12:23 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 255531E80CD5; Thu, 1 Dec 2022 23:12:23 +0800 (CST) From: Li Qiong To: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yu Zhe , Li Qiong Subject: [PATCH] net: sched: fix a error path in fw_change() Date: Thu, 1 Dec 2022 23:15:32 +0800 Message-Id: <20221201151532.25433-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The 'pfp' pointer could be null if can't find the target filter. Check 'pfp' pointer and fix this error path. Signed-off-by: Li Qiong --- net/sched/cls_fw.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index a32351da968c..b898e4a81146 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -289,6 +289,12 @@ static int fw_change(struct net *net, struct sk_buff *= in_skb, if (pfp =3D=3D f) break; =20 + if (!pfp) { + tcf_exts_destroy(&fnew->exts); + kfree(fnew); + return err; + } + RCU_INIT_POINTER(fnew->next, rtnl_dereference(pfp->next)); rcu_assign_pointer(*fp, fnew); tcf_unbind_filter(tp, &f->res); --=20 2.11.0