Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp4646082ybc; Tue, 26 Nov 2019 12:14:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzRfFqR0oA90s5LihA21plMW1YLhCmfatvBxvf2ZN5nKZrpWR5ITl/cFh/j9ki2qla/cMh4 X-Received: by 2002:a63:e94d:: with SMTP id q13mr291345pgj.209.1574799268153; Tue, 26 Nov 2019 12:14:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574799268; cv=none; d=google.com; s=arc-20160816; b=Qzgdyk3qzAJ2AMqNSyyQEGzBh7eCITgmj/RtAwOoR44A5qj+MTkLsesqk1NB/Gieds SOT3LfckYKsepyvt0eLoXuPOAx9zLKaZMhrZSI17pgiUXffRKnmNVz3ep1BfkZqTQYv1 m9/QWSvYJ6nT1RTuVTmuzfuMafkfYzh9BkHFGw+x2HByQzyte33VwlVCxrGDcmv5wMdj lS2/Nt1r0sUcbYsLFdtK2gQvRWZrv08jnNNB+jeRPovxLkLdAkFkZzEAWyhc2bm4t3Zr 4fQuhzpcFOtd/7NkkmpdxsUiy/vfdLvYSh/GBI1jpDBzI3RL5Fg0azYRt08P/D7q2zU1 jiZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nWXvBe8iHv2e1HrWC91gojWLhn523EghSo2ykxPHbqU=; b=Ci3/XQ5wJ4NSzDTEY3dMR7MsHbNYgOFp+oVi4pxIg21j4+UzwmzuHV+T8bx8q+BqU4 qmddNT6SZmSbEiD1IHaHWBWLJTG/LClE2j3Y289WktaiBCZex2Z6ELhgv7wABHdem1jP iE9gfFO7KkoVn+u/YVHlb+e6quJR9BMZUyssZF7jDLqWZzlIjzXajsMcLdHgL7c44661 Yc5q1kG8GgUnO3Apd7/DBKJeDE2547cFDI+657kX28I2ojQhC4jRswNu5ioQrdU6A1JT u2NdaMF73sJTOMAgJES46Q5XLtCZMQziLqlI78soI5RoZa3vvCwYFUmTRMHZMrtxGOZK RYZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pLKc4Sgt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si12508024pfi.47.2019.11.26.12.14.11; Tue, 26 Nov 2019 12:14:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pLKc4Sgt; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbfKZUNE (ORCPT + 99 others); Tue, 26 Nov 2019 15:13:04 -0500 Received: from mail-oi1-f195.google.com ([209.85.167.195]:44485 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfKZUNE (ORCPT ); Tue, 26 Nov 2019 15:13:04 -0500 Received: by mail-oi1-f195.google.com with SMTP id s71so17836908oih.11; Tue, 26 Nov 2019 12:13:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nWXvBe8iHv2e1HrWC91gojWLhn523EghSo2ykxPHbqU=; b=pLKc4Sgt83cCty7y3uDo50AVWsudPf7KjkxbiFHhdSHn3c2hRoSBDM2JLYBUxV1tSP SLjy0cv/dPXBO8Vs8FKEIDZnVBIoHAEtnVBgLry7mAN/WID2pmhomxJBagLj3D/VaWLe V8EuElcIdHPotR99lG1+4W8PNp+U0cLUrvdQ+zSHq+OUZbu0Yir3HR1jHnu1NZaUQg6J MjxXW/8lZ9B429oBOYF2wEwI4Qrr7wYFuLAab+t/KtrPBCCptxD2zD3r7sFWo3mpun3d hSbpTmnkFt2Kd87raS0SmtOz2I3jZtEODnjulXNoBvTmbwOzV0nkU8h7tYq+PUPSR57Z 1qDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nWXvBe8iHv2e1HrWC91gojWLhn523EghSo2ykxPHbqU=; b=AVodZ39JcWjvxEntNYvXQSazb4V83j8Hbi6n9QKGzju+upwrmD1JPc/pNiztz8p3gJ 0jgmgGXLsS4TxcaehyaDTr69hbvAt8I51/RQtaDjicffErUMUvMGjhn4tEFpHd9bfDV7 I6hHAnk8O6yf7ZEuglK/d1FHrkxvOS5FMwFe+hx0P/LPltkvCH8abBdKc9hTysveVIng F/JsX38fC+nyUll2zo4ofnoN4lF7txPjFqGtWFCa158dxK8NhY5nbQWBnvL+4Qj3qTKs codFw972H8PTJnLfo3dEn+1So9FpuDc+xHw93gQwdYV4vaxNViFhoSgQhE0vG/hJI6Di Usjg== X-Gm-Message-State: APjAAAU9EkgA9BNc+OjEgeVR/IvOWpX1N9InhvZBPtK0nwyAdG47vYKQ 0BNto77ZnUwQPfyYTVcjjNXXU5+r X-Received: by 2002:aca:b708:: with SMTP id h8mr787878oif.126.1574799182939; Tue, 26 Nov 2019 12:13:02 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::7]) by smtp.gmail.com with ESMTPSA id e186sm4033064oia.47.2019.11.26.12.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Nov 2019 12:13:02 -0800 (PST) From: Nathan Chancellor To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH] netfilter: nf_flow_table_offload: Don't use offset uninitialized in flow_offload_port_{d,s}nat Date: Tue, 26 Nov 2019 13:12:26 -0700 Message-Id: <20191126201226.51857-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns (trimmed the second warning for brevity): ../net/netfilter/nf_flow_table_offload.c:342:2: warning: variable 'offset' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized] default: ^~~~~~~ ../net/netfilter/nf_flow_table_offload.c:346:57: note: uninitialized use occurs here flow_offload_mangle(entry, flow_offload_l4proto(flow), offset, ^~~~~~ ../net/netfilter/nf_flow_table_offload.c:331:12: note: initialize the variable 'offset' to silence this warning u32 offset; ^ = 0 Match what was done in the flow_offload_ipv{4,6}_{d,s}nat functions and just return in the default case, since port would also be uninitialized. Fixes: c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support") Link: https://github.com/ClangBuiltLinux/linux/issues/780 Signed-off-by: Nathan Chancellor --- net/netfilter/nf_flow_table_offload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c index c54c9a6cc981..a77a6e1cfd64 100644 --- a/net/netfilter/nf_flow_table_offload.c +++ b/net/netfilter/nf_flow_table_offload.c @@ -340,7 +340,7 @@ static void flow_offload_port_snat(struct net *net, offset = 0; /* offsetof(struct tcphdr, dest); */ break; default: - break; + return; } flow_offload_mangle(entry, flow_offload_l4proto(flow), offset, @@ -367,7 +367,7 @@ static void flow_offload_port_dnat(struct net *net, offset = 0; /* offsetof(struct tcphdr, dest); */ break; default: - break; + return; } flow_offload_mangle(entry, flow_offload_l4proto(flow), offset, -- 2.24.0