Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp3446291pxb; Mon, 30 Aug 2021 02:20:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIkl+BO7iGSmONzkxxBM3FJRoh/ACUA3wwwnuFGd9oEmDiCEpewUQIBISGH5jyvTksdIXE X-Received: by 2002:a17:907:7817:: with SMTP id la23mr24618087ejc.43.1630315258306; Mon, 30 Aug 2021 02:20:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630315258; cv=none; d=google.com; s=arc-20160816; b=lQN5u13LmwtJcDbRzJ41OzJh9JJa3HQRMTlxvSzqJbQqnKC09uab85o5+RcfB1AVwY CLP+JyJnX09DGag1HsitqgJv7aYgfpRD76rM3KB9B15OKPL3fQgSYhE4DdM1pRiRNf1/ HUEGVk4ikQzhJFqkWUSozZsGmQmJ6qTRu3Ig6gZ4Lri9x75WGDAfzbv0VYQKRaWEuPB1 JHGtJhAdjVDGjgxHSVny7aYoaiEFyx3g9LtPQ7/GUXVwF2WE/OhvDJsgw9UojbewTDhR ioUo3ER5bTlI6jBh3CVv5j+apF2+xZyCPDYVjlslE32Nsa9PulBEACJTWkFH+63An8oW c5KQ== 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=RnZU/eiz4GTpQlhOPHQMTWd/YBLjcRvYkWNaDFjlT3A=; b=OsRTsuzkyR5LmkyV74Jtkpe2zMa1cNZ0uebEIMJyV4qDmXyV6pBT5EycasWh/r1tY6 5tr43HrUbwu3nDWt4K9bB5fvceddY1wquacPI2VWByjpYxOUw72os0btVL1Ej5uG6Km7 7VmyKqnWo8oWkQtIRMqAOwNHuLY0l7ScvKC/S54hBE3pAg+NMGBpopulFeatof7S4loe SvFBEfDtzxzFtIVIBDWIJvhb9rnCZB31ontlEPTMoX/NgEFFgun8xd4ye9xPVI5q5zUU bioZ7kgmk2riDlCdxj6y1qQ9CmfOdOQBd+mDvA5kn7f/aERMvLUpkczyjc4keKizSzAb oZvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=VnMxU5Ro; 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=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gc38si2099274ejc.395.2021.08.30.02.20.33; Mon, 30 Aug 2021 02:20:58 -0700 (PDT) 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=@linux.dev header.s=key1 header.b=VnMxU5Ro; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235270AbhH3JRu (ORCPT + 99 others); Mon, 30 Aug 2021 05:17:50 -0400 Received: from out1.migadu.com ([91.121.223.63]:16849 "EHLO out1.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235042AbhH3JRt (ORCPT ); Mon, 30 Aug 2021 05:17:49 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1630315014; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=RnZU/eiz4GTpQlhOPHQMTWd/YBLjcRvYkWNaDFjlT3A=; b=VnMxU5RoF+peuR8YKJyyKmseBGFc2tMlgVknNtQfxcdL35EElLiQ6HuwsDnEYucS9SfTrq DN56XFvLbhnpnYSJcaZUGLhysScqHkKHFCQzhCPNWvaQEKAXccyxYVxCA8AD23HoZAcynF 8/tUBZjRzov70oVngtpWi2lGKbLmFCE= From: Yajun Deng To: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng , Dan Carpenter Subject: [PATCH net-next] net: ipv4: Fix the warning for dereference Date: Mon, 30 Aug 2021 17:16:40 +0800 Message-Id: <20210830091640.14739-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 9a8f05d5476e..9bca57ef8b83 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -825,7 +825,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.32.0