Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4739964pxv; Tue, 20 Jul 2021 10:28:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/XjA+rbLsa/yVNOQJ0rU7wIywXXrrhuc4GpQJLhFO7097cTeRu4GJzOMM3BjKP5FF2P/e X-Received: by 2002:a17:906:8a67:: with SMTP id hy7mr33665402ejc.421.1626802137029; Tue, 20 Jul 2021 10:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626802137; cv=none; d=google.com; s=arc-20160816; b=J6hLAbsEWCAZuBMEdCtMqcjnoY6RGFaAI2T6BBR0L1ABq/xzMFEYka88McTCTR7EzV jGat6YBqTtOn6+tyi2kLvhk9HICjg0wOArxHn68umONFY9U83J20Xg2s6Y4f8Is+C/hk g47OpeuaUJg/DdSg45NABbO5eRwBHPSBdxprJ+Ow7LXGWZpHUq7dOpTSuNtdsBEktsl2 og8A8woY75ychH7NZLSNKTldEsah5dyIS09eBzuviL01fCF4jDZ5e1y6rXZTpLIcVsaj 4+h8W2b1nQ0Bs6hX5eHJQ82QTCrc4zN/Yqv4h+vDKnNX4lQHNUZUo6Itz8I+PxAr6E5i a95g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9MOPCzw9qH9RYH6V7cHhosLF/Y+XvdDzYIsFfB0esh8=; b=ItcHb5T5ELZp56yoiosoKZQ/q7pd9/8VVkLYi6GUK4Hp4wjyKQqDQ9IIWwb/DsW4x9 jSqD5LUvgtyaul3BPH/y0p120+YRVlG6CyLl6yzDfuV33PtS7oejqb92lAcW6oaMWlOq 4vqrwtmvT1j1/bTWG6lzvAuccHJw/v4bpzc/bn7/zA5ms2uBuHvv91Vv8SzaZFWjv0/D 3baOsuaaAdodJIcpJ3NPOiaOx/ETrj2NItZQjuXuEFIGI33pgh73fOpyvqz7EWEq/HU6 fpSHzq1L8+lDOAHM/y8iTnZP8/VK5W8vebIuOSYysFHJmGCgblENxyIHg3Nrd+wlWV2/ h2GQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si27032655edu.434.2021.07.20.10.28.33; Tue, 20 Jul 2021 10:28:57 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbhGTQqS (ORCPT + 99 others); Tue, 20 Jul 2021 12:46:18 -0400 Received: from mga09.intel.com ([134.134.136.24]:23531 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231910AbhGTQmv (ORCPT ); Tue, 20 Jul 2021 12:42:51 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10051"; a="211286204" X-IronPort-AV: E=Sophos;i="5.84,255,1620716400"; d="scan'208";a="211286204" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2021 10:19:31 -0700 X-IronPort-AV: E=Sophos;i="5.84,255,1620716400"; d="scan'208";a="462117412" Received: from tjathaud-mobl.amr.corp.intel.com (HELO ldmartin-desk2) ([10.255.230.66]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2021 10:19:27 -0700 Date: Tue, 20 Jul 2021 10:19:27 -0700 From: Lucas De Marchi To: Colin King Cc: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Anusha Srivatsa , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] drm/i915/xelpd: Fix unsigned compared to less than zero error Message-ID: <20210720171927.joohdb6lykm7j64t@ldmartin-desk2> X-Patchwork-Hint: comment References: <20210720155726.73628-1-colin.king@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210720155726.73628-1-colin.king@canonical.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 20, 2021 at 04:57:26PM +0100, Colin King wrote: >From: Colin Ian King > >The subtraction of fw->size - offset is operating on two unsigned >integers and the result is unsigned and hence the less than zero >comparison will always to be false. Fix this by casting fw->size >from a size_t to a ssize_t to ensure the result can be signed to >allow a less than zero result. > >Addresses-Coverity: ("Unsigned compared against 0") >Fixes: 3d5928a168a9 ("drm/i915/xelpd: Pipe A DMC plugging") >Signed-off-by: Colin Ian King Reviewed-by: Lucas De Marchi thanks Lucas De Marchi >--- > drivers/gpu/drm/i915/display/intel_dmc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c >index f8789d4543bf..dde1f243d375 100644 >--- a/drivers/gpu/drm/i915/display/intel_dmc.c >+++ b/drivers/gpu/drm/i915/display/intel_dmc.c >@@ -645,7 +645,7 @@ static void parse_dmc_fw(struct drm_i915_private *dev_priv, > continue; > > offset = readcount + dmc->dmc_info[id].dmc_offset * 4; >- if (fw->size - offset < 0) { >+ if ((ssize_t)fw->size - offset < 0) { > drm_err(&dev_priv->drm, "Reading beyond the fw_size\n"); > continue; > } >-- >2.31.1 >