Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5726813pxb; Thu, 20 Jan 2022 03:23:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGOhfpck1a/f7tXIrYXITpumL5I1l19tXbU+wYnFimMxJCG8JBTtVAaXOg4ftw5ECHuAB8 X-Received: by 2002:a17:90b:1bc3:: with SMTP id oa3mr10331481pjb.131.1642677793168; Thu, 20 Jan 2022 03:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642677793; cv=none; d=google.com; s=arc-20160816; b=yJyzwIq8gL/38iWMQjQDXEvHliUvnG1GGTx4pWEf03h4pEUmOYpHBY3qsQOuD8R+t0 xpWenfiCmINlhsKmfREyhpy5QlOib8ikevYI6iqoZsYZstCE9Mghr3cKYtKr/5ZsaX6R vEi4yFc4YADkrbR0Y3Y3ogk2fBN8UEKQYrtLFDeEsp2FfWEoN6h3yFl5DZkvW6Efyqth lzMPTlS53VFddLqfqvyWZE7rGdho76xI3PjYMeIyuK+fJKfcoDHfxnubdgUDU/cwIruv ePPK5MfF7uH2bRV4tUfEW4bD5G7R/Q+6kGQdbu1t8E1dMAu/D+H4MeLj1YbByVdxoRyq uZQQ== 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=OjmFL8JLFpwgH42MBB6gml2GfGQI5Vtp3QaY21Donc4=; b=t1WnTR+xfdS/Mn2E2yUlr42kGUKF6FrAMj3jS+uBcL7hpmJFKUMpiDuJmhPmdJqLUI XTixWgirOyQUB+9V4KBH6hYRjKYau9/7BECpmWB5hfU2B2iaZ5+Ngz3uUz7eo3h7ouuP h4iVVzsuLLaQaJ50HPX6/CumMQhErapnSftcK9KM/42DiTuYlw/QQsD0i7VG7AKIVH41 G8avIt6aF2PbiaQU+nTpK+JCiEvEsYBOe15p3cpozAKQLUNUcQ6gHpe695ho/LjVrFd8 x1YE4At0nik4Ng+wiLaiq5rN7jqyHJ8G6uMqJnoM8LiChQtZFyuKwbbhf5TXkKR63x+6 l36A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iiEmjCb1; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si2710777pjk.76.2022.01.20.03.23.02; Thu, 20 Jan 2022 03:23:13 -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=@redhat.com header.s=mimecast20190719 header.b=iiEmjCb1; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242951AbiARNl0 (ORCPT + 99 others); Tue, 18 Jan 2022 08:41:26 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43848 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242919AbiARNlV (ORCPT ); Tue, 18 Jan 2022 08:41:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642513280; 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=OjmFL8JLFpwgH42MBB6gml2GfGQI5Vtp3QaY21Donc4=; b=iiEmjCb1uJnvunEkuMUxkBf0LhJkzAYHfcnUGpiuW262DopI/nnjmHFcekFBBPM4fObkLI m3on0jIM+x5B72eH+ovPDVj71S6yK1jTnVRmHDtgqIDLko+lQ8COE+UEjCBeqBRN5mLFmw mIrexX2k0MuuW+woKqOB2e5zIl4+lnU= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-528-y2i03z_uM7mp-HqdccH1yg-1; Tue, 18 Jan 2022 08:41:19 -0500 X-MC-Unique: y2i03z_uM7mp-HqdccH1yg-1 Received: by mail-ot1-f69.google.com with SMTP id y11-20020a056830070b00b00595da7db813so6276709ots.16 for ; Tue, 18 Jan 2022 05:41:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=OjmFL8JLFpwgH42MBB6gml2GfGQI5Vtp3QaY21Donc4=; b=jTm6v0YghtuZwK6r/SafgMVOmk2agT9p6pPyyLhXdlH/wqAGGrBlLz8g28nZi6lOE+ jopjdUXj33DzMEFcV7HCaZFhWvyPAMIdPLFOeLkea47PYabuZzqqdTuV/PZtypuzwnbo T/siWgyQm/WJmhcQEy1y1wlqVKWEQ13wnnCo3sri3UQt7rzg2/R+F8GQf6k6h9KLF0PF 0/FJD1zuW08W3mEMsHT17lu49PdgtGIb78fPidOYd7JCB7fG05CIvMjJRViuLzlJZ0+7 St8FvMCrhWPDVVLf2THQJXoTODsQGfhtO8pH+HsdA2uIw+UQUfCyQDO6TW1smxczFsim Qmmg== X-Gm-Message-State: AOAM53371vNccO5Nh4BiEAuQsL6VV9j4EPuhFWPI+vYokkF0cohJ8qju pJRDKDY2tbMdkd8Qi3koH1TkVtsLBBEgdMpJU0NjpxnSotqzUcgOQZ7pMv2WVAkrUwsNmnqtnb1 cuw5KRl9mUlHQxq3z8PBIlCfi X-Received: by 2002:aca:1e0b:: with SMTP id m11mr1660649oic.79.1642513278684; Tue, 18 Jan 2022 05:41:18 -0800 (PST) X-Received: by 2002:aca:1e0b:: with SMTP id m11mr1660614oic.79.1642513278337; Tue, 18 Jan 2022 05:41:18 -0800 (PST) Received: from localhost.localdomain.com (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id f12sm6883770ote.75.2022.01.18.05.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 05:41:17 -0800 (PST) From: trix@redhat.com To: vladimir.oltean@nxp.com, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, davem@davemloft.net, kuba@kernel.org, nathan@kernel.org, ndesaulniers@google.com, xiaoliang.yang_1@nxp.com Cc: UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Tom Rix Subject: [PATCH] net: mscc: ocelot: fix using match before it is set Date: Tue, 18 Jan 2022 05:41:10 -0800 Message-Id: <20220118134110.591613-1-trix@redhat.com> X-Mailer: git-send-email 2.26.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix Clang static analysis reports this issue ocelot_flower.c:563:8: warning: 1st function call argument is an uninitialized value !is_zero_ether_addr(match.mask->dst)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The variable match is used before it is set. So move the block. Fixes: 75944fda1dfe ("net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1") Signed-off-by: Tom Rix --- drivers/net/ethernet/mscc/ocelot_flower.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c index 4a0fda22d3436..949858891973d 100644 --- a/drivers/net/ethernet/mscc/ocelot_flower.c +++ b/drivers/net/ethernet/mscc/ocelot_flower.c @@ -559,13 +559,6 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress, return -EOPNOTSUPP; } - if (filter->block_id == VCAP_IS1 && - !is_zero_ether_addr(match.mask->dst)) { - NL_SET_ERR_MSG_MOD(extack, - "Key type S1_NORMAL cannot match on destination MAC"); - return -EOPNOTSUPP; - } - /* The hw support mac matches only for MAC_ETYPE key, * therefore if other matches(port, tcp flags, etc) are added * then just bail out @@ -580,6 +573,14 @@ ocelot_flower_parse_key(struct ocelot *ocelot, int port, bool ingress, return -EOPNOTSUPP; flow_rule_match_eth_addrs(rule, &match); + + if (filter->block_id == VCAP_IS1 && + !is_zero_ether_addr(match.mask->dst)) { + NL_SET_ERR_MSG_MOD(extack, + "Key type S1_NORMAL cannot match on destination MAC"); + return -EOPNOTSUPP; + } + filter->key_type = OCELOT_VCAP_KEY_ETYPE; ether_addr_copy(filter->key.etype.dmac.value, match.key->dst); -- 2.26.3