From patchwork Thu May 13 23:28:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Souza, Jose" X-Patchwork-Id: 12256831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30CCFC433B4 for ; Thu, 13 May 2021 23:25:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E05A161421 for ; Thu, 13 May 2021 23:25:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E05A161421 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A5676EDE5; Thu, 13 May 2021 23:25:43 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2332E6EDE5 for ; Thu, 13 May 2021 23:25:42 +0000 (UTC) IronPort-SDR: gRqfmJ8Rvq1IRugYtU1fpF8m2uH4ZueibNyY+D9aBWpRAngP2jUB9OdZ5H1gHEAAGrj2pK81Nn vaNNZNwRNpVw== X-IronPort-AV: E=McAfee;i="6200,9189,9983"; a="179672435" X-IronPort-AV: E=Sophos;i="5.82,296,1613462400"; d="scan'208";a="179672435" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2021 16:25:41 -0700 IronPort-SDR: /uEflHyUvsxjt8oVUMozMHtv6/1zykkWsebdVE37hI0+zWtPpLIXsLQSC/U/+7ZIX8U72DS3Nv F29+jF+NKPSg== X-IronPort-AV: E=Sophos;i="5.82,296,1613462400"; d="scan'208";a="392480976" Received: from psethi-mobl3.amr.corp.intel.com (HELO josouza-mobl2.intel.com) ([10.254.1.112]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2021 16:25:39 -0700 From: =?utf-8?q?Jos=C3=A9_Roberto_de_Souza?= To: intel-gfx@lists.freedesktop.org Date: Thu, 13 May 2021 16:28:41 -0700 Message-Id: <20210513232841.147989-1-jose.souza@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH] drm/i915: Fix a possible use of uninitialized variable in remap_io_sg() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoph Hellwig Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" If the do while loop breaks in 'if (!sg_dma_len(sgl))' in the first iteration, err is uninitialized causing a wrong call to zap_vma_ptes(). Fixes: b12d691ea5e0 ("i915: fix remap_io_sg to verify the pgprot") Cc: Christoph Hellwig Signed-off-by: James Ausmus Signed-off-by: José Roberto de Souza Reviewed-by: Christoph Hellwig --- drivers/gpu/drm/i915/i915_mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_mm.c b/drivers/gpu/drm/i915/i915_mm.c index 4c8cd08c672d..25576fa73ff0 100644 --- a/drivers/gpu/drm/i915/i915_mm.c +++ b/drivers/gpu/drm/i915/i915_mm.c @@ -47,7 +47,7 @@ int remap_io_sg(struct vm_area_struct *vma, struct scatterlist *sgl, resource_size_t iobase) { unsigned long pfn, len, remapped = 0; - int err; + int err = 0; /* We rely on prevalidation of the io-mapping to skip track_pfn(). */ GEM_BUG_ON((vma->vm_flags & EXPECTED_FLAGS) != EXPECTED_FLAGS);