Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp861266pxb; Tue, 1 Feb 2022 11:59:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6pdRl/N/F7wvg2gJjh6L6gE2ZAVega6MDK3CS+4LWyu+BpDeZ9rZy79ryk4J85i5FptUX X-Received: by 2002:aa7:dbcc:: with SMTP id v12mr26902123edt.263.1643745544292; Tue, 01 Feb 2022 11:59:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745544; cv=none; d=google.com; s=arc-20160816; b=QSOYXUgg3nxwx1PY0/prQmLLCnZiI0bnpC5YNcR/LDniZhh4S15Ovn7K1EBzg/h4Jk L/4iShYhMo+ubEA8iRgzNAnLzQX9W+riXgmdZfyJZrSC/EhaWmcSYx1iIWXI8st9Xz+D ShIADpXFYZeDDqIbZjG9dkXlb8Lwq6l4nu36QXhMl6zEhHpIVeEOIOzu9qzae2vwNPda 8WEXknQZ6ZzpHrYm78KSJo93r2j766jNl1MKiFXnCbm8l9UKhJ72Z6y87fG5BWFnvp7r ty+Wf/aYdWZ5pwHiRndFV6OkKYjFxz0BBO1MDZyTgMKLVw65ori4zDFY9cLK1qFn5MiJ rMHg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=edudTEWmdgk3195qs4XbpoTfsztAQ4SFRWp+UlN2o3A=; b=SUvt9eATKYsvwDtgJaTvnB/jYh6QLXl+NoDl/urqMBG1iIHUrTitg4m7aASSDsV5VF WkazAMK9qTrpsRQ8xKE+KhBGlWDqrllnwF9AwC9vwhXRbBMj1GkGO6pVhBqwQcDLEy5W xEKZbLQM1Amx3IuUB7a4l5p59aKRmaiRKNujOJJdYQIcZadxxPrQM0U4CLD3tlWunyk6 KyGlFLhekGCvx7OcQ3zhmf0SxOAyY6U6yYPbQD09ZsZLFjBSjE1oU3dSmHGCLsvSCJEt RBgHU9KJZ6O9BEuqR/Dmx72J7bbDJXF4+GOWi3I3L703EI7YRf/pzTXczRMfdt/VhEB9 1S1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YkZSV1x0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs13si10901065ejc.747.2022.02.01.11.58.38; Tue, 01 Feb 2022 11:59:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YkZSV1x0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376488AbiAaLIc (ORCPT + 99 others); Mon, 31 Jan 2022 06:08:32 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:38682 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358994AbiAaLFV (ORCPT ); Mon, 31 Jan 2022 06:05:21 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1207360B98; Mon, 31 Jan 2022 11:05:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0558BC340EF; Mon, 31 Jan 2022 11:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627120; bh=hRGw969o3xfx3kaJXxvceU8n0eam0mIvnot3klzJX4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YkZSV1x0U2qugzhKdw2ieREP3/qwmM4D5ggY8m//DZdbjNcUecLBEbov9uzIY2Yc/ HTnA9RgoqgCyue1AP8/RmAS1rTH7RtVYsh+8zaFzNn8cT2MgAj6NBJ/81Bv42eUSaN DuYh8Yqs2pZnpGynlu8q26Cf7Znwue4QGTCKBoVo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Yajun Deng , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 081/100] net: ipv4: Fix the warning for dereference Date: Mon, 31 Jan 2022 11:56:42 +0100 Message-Id: <20220131105223.166114763@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105220.424085452@linuxfoundation.org> References: <20220131105220.424085452@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yajun Deng [ Upstream commit 1b9fbe813016b08e08b22ddba4ddbf9cb1b04b00 ] Add a if statements to avoid the warning. Dan Carpenter report: The patch faf482ca196a: "net: ipv4: Move ip_options_fragment() out of loop" from Aug 23, 2021, leads to the following Smatch complaint: net/ipv4/ip_output.c:833 ip_do_fragment() warn: variable dereferenced before check 'iter.frag' (see line 828) Reported-by: Dan Carpenter Fixes: faf482ca196a ("net: ipv4: Move ip_options_fragment() out of loop") Link: https://lore.kernel.org/netdev/20210830073802.GR7722@kadam/T/#t Signed-off-by: Yajun Deng Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ip_output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index fb91a466b2d34..e77afaecc9818 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -833,7 +833,9 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, /* Everything is OK. Generate! */ ip_fraglist_init(skb, iph, hlen, &iter); - ip_options_fragment(iter.frag); + + if (iter.frag) + ip_options_fragment(iter.frag); for (;;) { /* Prepare header of the next frame, -- 2.34.1