Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp812597rwb; Thu, 1 Dec 2022 08:39:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf7YWliZqmIq44vshG2MIXOHOqulUT2mnZSlpb064WBv+t4FMuPKw90Vc6pSKLRyrhOD1jcv X-Received: by 2002:a17:907:6744:b0:7c0:8d04:d1f1 with SMTP id qm4-20020a170907674400b007c08d04d1f1mr10525350ejc.208.1669912782897; Thu, 01 Dec 2022 08:39:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669912782; cv=none; d=google.com; s=arc-20160816; b=LYcXXYL/ewOr2xlIynchZD8kH/nGk1CQRzpBWI+s77VT2L6fwrme/0bXQDyLl0wMyE w9BBBeouhjrXflxZZEzFPxlmNTc96drvsobYBgLWuHwqkQIPnIQuql9V8+8cjDLEct2B CUhqD4ktIVrElPpLBO2wXqf0SC0Ml1NcCza2C2/lz9biWMAvrUfn7OBJ5hHScoHYVjFh QP1VIvsztu6bOllPFG2XWHTb2cVTWkueflXLWV+yc5NHaYuDaVwZRFT0nKcyG2gnODCm YhJ8MpGGJYoQ3EqZMXTjXUHTKBY+uD2+GoDEt7P5n1luOuv5XKzdvr/doEfEuRWF4n5F aW+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=7QHyH2+9R4XjKa3yPYPEFQpefQRCRNjhYibD6vw8lFI=; b=VIZK3eXPG00nBr1SnrEQLAs0e1u3JeeHuKHaEfG5dLrXZi2VNm8ZHAdg6sUpc6jkMg RpsfF5ccHFYLMYAroFMh0kfmcR6YEdERqW7PnrUODe3B85RwQ43BmiNyULjs7e1toxIB 9v5imwKEwx0wsxNhlaA3NTe5wIwiGWO0Khn1NWcpuFxLGD49SvknBFYyRFa+avGpPEYZ 01UF9n8nWXUWIN8KnI7WDsJueyG1R1iK0z88EkmV2Y4Y4rsXdetFHOMMCUcYqy9zrglo 3Tz3BSLeMYeThp6ShfLUnW3T+gF8N44LYwpjSO+e6yxSmMq6tA1g9rfVK1TInv7RuT0H qadg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz18-20020a1709077d9200b007bf5128a8ecsi3978863ejc.466.2022.12.01.08.39.22; Thu, 01 Dec 2022 08:39:42 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbiLAPQd (ORCPT + 82 others); 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 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 == f) break; + 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); -- 2.11.0