From patchwork Mon Feb 6 16:13:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1738250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ElcICijS; dkim-atps=neutral Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P9WWQ1cvPz23j0 for ; Tue, 7 Feb 2023 03:12:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5349B60B33; Mon, 6 Feb 2023 16:12:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 5349B60B33 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ElcICijS X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gAevpJ3aTVbm; Mon, 6 Feb 2023 16:12:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 86CD860B23; Mon, 6 Feb 2023 16:12:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 86CD860B23 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6272EC0033; Mon, 6 Feb 2023 16:12:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 22ABAC002B for ; Mon, 6 Feb 2023 16:12:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id F120060B2C for ; Mon, 6 Feb 2023 16:12:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org F120060B2C X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GlHe3OqXs7QY for ; Mon, 6 Feb 2023 16:12:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 44CEA60B23 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by smtp3.osuosl.org (Postfix) with ESMTPS id 44CEA60B23 for ; Mon, 6 Feb 2023 16:12:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675699964; x=1707235964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l/z8Ht549NtECTSxHC6f4gPVeQdnVs1kMMhg97KXrdY=; b=ElcICijSmWubzlx63RORU8S54xKAXeKuIJfW4fAiZL35b0B+szfKbYQT 8sMKt/VJWfDQ1VLROOD3MiwjyMp2la/R6woUEM398MNUCsjlLBPMnPZu9 +ap2LkR3vw+seZRhG8+qTOQ3bbtQPNeL3PQ67Vj8CEGUYL09Kh4PAti0q +xkFWtlxXVJefPmlUc/cmkRF8rKwn7loJkhRDkmD4lLJznpC2umbm/6hi PQM0HuSqql/lJCLk6p0MfZGkGoL78R2e726JMWB7F/q9vg/j3tAcRLw3c V5tXSZUZGIEoVB2HVyxqPwPZxAA+wUaA6vqqW2ALHuVCANUFSFsC4S7m2 w==; X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="393840632" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="393840632" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2023 08:12:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10613"; a="696902426" X-IronPort-AV: E=Sophos;i="5.97,276,1669104000"; d="scan'208";a="696902426" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 06 Feb 2023 08:12:37 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 02DAC27B; Mon, 6 Feb 2023 18:13:15 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Jakub Kicinski , Xin Long , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, dev@openvswitch.org, tipc-discussion@lists.sourceforge.net Date: Mon, 6 Feb 2023 18:13:14 +0200 Message-Id: <20230206161314.15667-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230206161314.15667-1-andriy.shevchenko@linux.intel.com> References: <20230206161314.15667-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Cc: Andy Shevchenko , Simon Horman , Jon Maloy , Eric Dumazet , Ying Xue , Paolo Abeni , "David S. Miller" Subject: [ovs-dev] [PATCH net-next v2 3/3] openvswitch: Use string_is_valid() helper X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Use string_is_valid() helper instead of cpecific memchr() call. This shows better the intention of the call. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Horman --- v2: added tag and updated subject (Simon) net/openvswitch/conntrack.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 2172930b1f17..1d65805e79b4 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1383,7 +1384,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, #endif case OVS_CT_ATTR_HELPER: *helper = nla_data(a); - if (!memchr(*helper, '\0', nla_len(a))) { + if (!string_is_valid(*helper, nla_len(a))) { OVS_NLERR(log, "Invalid conntrack helper"); return -EINVAL; } @@ -1404,7 +1405,7 @@ static int parse_ct(const struct nlattr *attr, struct ovs_conntrack_info *info, #ifdef CONFIG_NF_CONNTRACK_TIMEOUT case OVS_CT_ATTR_TIMEOUT: memcpy(info->timeout, nla_data(a), nla_len(a)); - if (!memchr(info->timeout, '\0', nla_len(a))) { + if (!string_is_valid(info->timeout, nla_len(a))) { OVS_NLERR(log, "Invalid conntrack timeout"); return -EINVAL; }