Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1943562lqb; Mon, 27 May 2024 02:45:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUfobaFI4cgmFk6yC87b65jDyscV4ylltLRYIu3qs8DFERfpwDnch2RlXRfG1k0+AtHeS/JhHuPJAcKJZ+z4598SDCCOokx7lGpE724Qw== X-Google-Smtp-Source: AGHT+IF2TQ0Gd3n5WrxsnAEDQ6Jv9igwoxkjjOP3jhdaz/AxVKG8A15YNQ6PQRZWxOI6u40z0rFU X-Received: by 2002:a17:906:63ca:b0:a59:a9c5:e73b with SMTP id a640c23a62f3a-a62647ce012mr519477466b.46.1716803126130; Mon, 27 May 2024 02:45:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716803126; cv=pass; d=google.com; s=arc-20160816; b=jpBhTbD1vrZdywvb3ILu+IQhK4M3JTr02huLcvew8NqpmHJe278SwLsfpbD/BdDsUi 2tleDGgodLhJnqfe2BRKeQwZZLmnwRlLMYYsLYRT/Fe2nKuOtnix8wFvMLHgcf0e4Vec 8Clwn1zP4bPqBqdq5am/Lv594Wx+ohKoD0ZYbWLlkMKZnfV4lZ/tLBJ415GOPfnhVp6c VyUvRtyk/ELTy5URSrzbSPDFPAL655x+oUNNHu0eJN1cEhNJvcD+HxzNqpgu3IKAe92E OootAaEEKKeSmGVy6/KAsA0JE5KF5Q0RYhsNlAxyfKF/+l0r/4lJK3+tCesWHM3txgGd IjIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:organization:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=0WE1tayptxAN7YuCVQ7qWHcNEX0Uy79cbVlyw7EyC+Q=; fh=TjjcPGtElYizzUgd7E1us6euwawFH6m7lu+gJrpA4Ow=; b=FIN7fv/Boou+rUJB7pLvtEr02jSp+TQWaeSz6h6Oxz4eqKL5W6JmrXa5bNIuADBqBx lrlZRYYnIBnVbgj9t6cG3xXnixhF2QKKdFFE9BQGD31RYnb6MvTo7ogRpjJ+uFaza2I4 /QUO/5BItqrf6jcsqyvp/rXtvX7pt6nTKTRMvdV9GvCir3VgWAqjSGmPSXNPHd9EG2Ir xX/XrLHJxd21SxTS4+NH8BvbpiYk+HVhFOp9d/MaqT+qiAOgOzO75LcejT/EQ4IwXo1E 9vgXj5v+NS/uWPtuV74fsQXu460QCiP26qhUTZmullbHNgRjFjkBEi9SOrQvP4BnCvv7 FLXw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kjPVcqnm; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-190368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cd95957si368456766b.873.2024.05.27.02.45.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 02:45:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kjPVcqnm; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-190368-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190368-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8BDAB1F23137 for ; Mon, 27 May 2024 09:44:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FFBC13AD2F; Mon, 27 May 2024 09:43:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kjPVcqnm" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DD1E2232A for ; Mon, 27 May 2024 09:43:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716803019; cv=none; b=RDnA/FDFCmyNHoJdFSxJWQ4bUSYVX36UwXKErd6jZxD+/En+jSIZj4BTbmcHjpR6gf8QkXe1wANybnVA+3pSkjMJ0m2OJUu16pbgGXj/l9IKor+dfbmGTg2wyoX6lJHz6ThCHsGPU9qMwj88W+tZiBrZE6jB4xku6A0V0mJGVFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716803019; c=relaxed/simple; bh=kX/sBp/2yGju2wTUjHprdWNQAUXdkMNFUKH9WEbbo14=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RmoNHDx+T2ey+4d2XXnnhUDFArMUd2bVjC+pfoUKpBkrE5DVD8UQrkEt/rbf7ybrsgfEBnG4DgtnNOBUUGbFsBo2O6ALZehOWc5QowXc81b3ZGmI8SnLDFXLUMzPOLZudTlHMFPqC2BAJu0egX54Ib0Ze2Nl8HRkQRH+i3fn+LQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kjPVcqnm; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716803017; x=1748339017; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kX/sBp/2yGju2wTUjHprdWNQAUXdkMNFUKH9WEbbo14=; b=kjPVcqnmOMPrqzgbCXWGaPPOf2pzswVGs2vZmsZiBNK57ya1hQkUc3AH o5qE0L+X54ZM5TFHM+F8kIt8dlKmb0aPS50o0SaVyHue6lngTI8y52bh7 ot9+TwDtW6NwcPTQjN2XfMZw5oGg73GH5LQhDsWuTNuHrkdnLPBKUwbm1 oA1bVjxvfN7fTXS6OcO288zNfZMe6VN0kzpJLhiUL/hjQtOHDyw+Ia6cC ZwjWsqmts+Wxm3ms/rZv2R0NUdH6l6b8Vnf2Jks3mvefysf8Mk3WvY9JM LQtGJHCygfwAa1OTrxc7cse6HGyOA0xZ0zsSe7AwGmpi3KjGbJf9Dk3SJ Q==; X-CSE-ConnectionGUID: mJPUOPt2TLmyAX1dPA6Z4w== X-CSE-MsgGUID: JCsaXBH0R4O6ZcsrqkzytQ== X-IronPort-AV: E=McAfee;i="6600,9927,11084"; a="30622010" X-IronPort-AV: E=Sophos;i="6.08,192,1712646000"; d="scan'208";a="30622010" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2024 02:43:37 -0700 X-CSE-ConnectionGUID: BU8w17P/RTOaD3mKYYsjRg== X-CSE-MsgGUID: ltom8v50RYuZpBF6zoHqSA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,192,1712646000"; d="scan'208";a="35187640" Received: from lfiedoro-mobl.ger.corp.intel.com (HELO localhost) ([10.245.246.200]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2024 02:43:35 -0700 From: Jani Nikula To: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, jani.nikula@intel.com, Kees Cook , Andy Shevchenko Subject: [PATCH 2/2] drm: use mem_is_zero() instead of !memchr_inv(s, 0, n) Date: Mon, 27 May 2024 12:43:20 +0300 Message-Id: <20240527094320.2653177-2-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240527094320.2653177-1-jani.nikula@intel.com> References: <20240527094320.2653177-1-jani.nikula@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Content-Transfer-Encoding: 8bit Use the mem_is_zero() helper where possible. Conversion done using cocci: | @@ | expression PTR; | expression SIZE; | @@ | | <... | ( | - memchr_inv(PTR, 0, SIZE) == NULL | + mem_is_zero(PTR, SIZE) | | | - !memchr_inv(PTR, 0, SIZE) | + mem_is_zero(PTR, SIZE) | | | - memchr_inv(PTR, 0, SIZE) | + !mem_is_zero(PTR, SIZE) | ) | ...> Signed-off-by: Jani Nikula --- Cc: Kees Cook Cc: Andy Shevchenko --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +- drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +- drivers/gpu/drm/drm_edid.c | 2 +- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- drivers/gpu/drm/i915/display/intel_opregion.c | 2 +- drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c | 2 +- drivers/gpu/drm/imagination/pvr_device.h | 2 +- drivers/gpu/drm/udl/udl_edid.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 516eb3968e26..7d847021ddc9 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -2432,7 +2432,7 @@ static void resume_mst_branch_status(struct drm_dp_mst_topology_mgr *mgr) goto out_fail; } - if (memchr_inv(guid, 0, 16) == NULL) { + if (mem_is_zero(guid, 16)) { tmp64 = get_jiffies_64(); memcpy(&guid[0], &tmp64, sizeof(u64)); memcpy(&guid[8], &tmp64, sizeof(u64)); diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c index 7f8e1cfbe19d..3d3097422235 100644 --- a/drivers/gpu/drm/display/drm_dp_mst_topology.c +++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c @@ -2697,7 +2697,7 @@ static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr, { u64 salt; - if (memchr_inv(guid, 0, 16)) + if (!mem_is_zero(guid, 16)) return true; salt = get_jiffies_64(); diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index f68a41eeb1fa..9970c22f616b 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1817,7 +1817,7 @@ static int edid_block_tag(const void *_block) static bool edid_block_is_zero(const void *edid) { - return !memchr_inv(edid, 0, EDID_LENGTH); + return mem_is_zero(edid, EDID_LENGTH); } static bool drm_edid_eq(const struct drm_edid *drm_edid, diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c index c0a3b6d50681..be3685e115ab 100644 --- a/drivers/gpu/drm/i915/display/intel_dp.c +++ b/drivers/gpu/drm/i915/display/intel_dp.c @@ -5055,7 +5055,7 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp) ack[3] |= DP_TUNNELING_IRQ; } - if (!memchr_inv(ack, 0, sizeof(ack))) + if (mem_is_zero(ack, sizeof(ack))) break; if (!intel_dp_ack_sink_irq_esi(intel_dp, ack)) diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index 68bd5101ec89..293c4d920cf9 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -1117,7 +1117,7 @@ const struct drm_edid *intel_opregion_get_edid(struct intel_connector *intel_con /* Validity corresponds to number of 128-byte blocks */ len = (opregion->asle_ext->phed & ASLE_PHED_EDID_VALID_MASK) * 128; - if (!len || !memchr_inv(edid, 0, len)) + if (!len || mem_is_zero(edid, len)) return NULL; drm_edid = drm_edid_alloc(edid, len); diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c index 3527b8f446fe..2fda549dd82d 100644 --- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c +++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_dmabuf.c @@ -506,7 +506,7 @@ static int igt_dmabuf_export_vmap(void *arg) goto out; } - if (memchr_inv(ptr, 0, dmabuf->size)) { + if (!mem_is_zero(ptr, dmabuf->size)) { pr_err("Exported object not initialised to zero!\n"); err = -EINVAL; goto out; diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/imagination/pvr_device.h index ecdd5767d8ef..b574e23d484b 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -668,7 +668,7 @@ pvr_ioctl_union_padding_check(void *instance, size_t union_offset, void *padding_start = ((u8 *)instance) + union_offset + member_size; size_t padding_size = union_size - member_size; - return !memchr_inv(padding_start, 0, padding_size); + return mem_is_zero(padding_start, padding_size); } /** diff --git a/drivers/gpu/drm/udl/udl_edid.c b/drivers/gpu/drm/udl/udl_edid.c index d67e6bf1f2ae..12f48ae17073 100644 --- a/drivers/gpu/drm/udl/udl_edid.c +++ b/drivers/gpu/drm/udl/udl_edid.c @@ -69,7 +69,7 @@ bool udl_probe_edid(struct udl_device *udl) * The adapter sends all-zeros if no monitor has been * connected. We consider anything else a connection. */ - return !!memchr_inv(hdr, 0, sizeof(hdr)); + return !mem_is_zero(hdr, sizeof(hdr)); } const struct drm_edid *udl_edid_read(struct drm_connector *connector) -- 2.39.2