Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp517454pxb; Thu, 9 Sep 2021 06:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJlbkEr3zK3l/rOuuxDPHanZLaCdFVdJAFphLweS+l0TWvHGM6ivnzVHldRdVCb7bCaDtf X-Received: by 2002:a05:6638:c4d:: with SMTP id g13mr2768358jal.43.1631193435525; Thu, 09 Sep 2021 06:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631193435; cv=none; d=google.com; s=arc-20160816; b=UZBO0+mCqyfdAAwqHYv04DthUMqLslyhSmpB7zBP4mjiLNukAmH/SZildBCxp8Z6lZ 2rC8OeoBuL0NtaeVe7maCDynCcAnIoRnvWCogqa06ZTDYYaa867k+wPcw/a00BU4ypin HSKYoAT7zm+2RjI9rmcOf5habAoWEcFVK588Apc49ykUIJTqlAnEFuDJ8va2ckljIJCu GuEewjebQd7Onjy7ffeX3UXcpCifO2wz0NH+LFDyDAv5WNgo5ckCh+UJus06/fju9PFb cUyvek4efE5D0gX8tFQM4w9w+WjljTADYiiWxlsRvIkOCGYES1NQHYr8ALNUh0Kcr3qg 8C9w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cqhucNoBLI1oFtbqhIXOYRHrUFXo2NV6hvkQigHMjZI=; b=u9Y3RPFAm2+mo78d53PPRM7zMOq+wd4BwcFcNyB7AwCEBF2w+a+hE3QVZaAe11HxfC IRF+ioglCNwT6PpNbNiC/7FerWm6p6zrJ95v1zlFlDmV9l4YKmfyhj5UP8a8vfTIYBkT K4HiWtM/yZZM2/F03C2hn/5qNZfgV9U3SHBIn6lWPQa4/AScUAIY7T8RwkCHtKHh4Xax WfMpbwmySTt/kSgmQJXuWtZq6D7Qgv6J872F7QCwRWd+QxhEbg3+zIowCZewSnjGL0A8 5YmAzxGTSRQZzR2nGl7sKhFZcDRGLyulW4g4DaN1sXdCJzhir3cVNoprDbIOKWcOhRy3 VW3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EgaqPTEP; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g63si1674664jab.37.2021.09.09.06.16.56; Thu, 09 Sep 2021 06:17:15 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EgaqPTEP; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359103AbhIINQP (ORCPT + 99 others); Thu, 9 Sep 2021 09:16:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:42454 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357666AbhIINDP (ORCPT ); Thu, 9 Sep 2021 09:03:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8954263294; Thu, 9 Sep 2021 11:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188786; bh=0af7XYpiDaqKh3arO7Wo+2DKVh53HZlCjD+rRxGqUBg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EgaqPTEPPsRHjJuLOabqlaLN8GwRj5jsV6a38ydbcmLGfm7iAsJ8Lqmrn0gXJao9f E6EbU+jxnfjmcqFfXFEqFcDesTxPGQqp1xcb1S8TJUk5Bgh/bXq2pNjzrzEogxA19j ubavicwRAmKjE+d5YYNhn7ddqZ/2DhyAHAJizvymzhz4hxwWgp7mOu/09L9sz04/S3 w7QN861T8k0qL7zO2pSrju0JfKpZEWuidhU4qqNvD10SK781lw+PQIWX5BACbAJ8/x dINkfG0foBM5cXIj/sWrF9OMS2wR5tJmgUfdbA9TSEzzItKay4q/5D3m+/Ye215Mts AlUjlh0BIK0dA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tuo Li , TOTE Robot , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.14 36/59] gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() Date: Thu, 9 Sep 2021 07:58:37 -0400 Message-Id: <20210909115900.149795-36-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115900.149795-1-sashal@kernel.org> References: <20210909115900.149795-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tuo Li [ Upstream commit a211260c34cfadc6068fece8c9e99e0fe1e2a2b6 ] The variable val is declared without initialization, and its address is passed to amdgpu_i2c_get_byte(). In this function, the value of val is accessed in: DRM_DEBUG("i2c 0x%02x 0x%02x read failed\n", addr, *val); Also, when amdgpu_i2c_get_byte() returns, val may remain uninitialized, but it is accessed in: val &= ~amdgpu_connector->router.ddc_mux_control_pin; To fix this possible uninitialized-variable access, initialize val to 0 in amdgpu_i2c_router_select_ddc_port(). Reported-by: TOTE Robot Signed-off-by: Tuo Li Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c index f2739995c335..199eccee0b0b 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c @@ -338,7 +338,7 @@ static void amdgpu_i2c_put_byte(struct amdgpu_i2c_chan *i2c_bus, void amdgpu_i2c_router_select_ddc_port(const struct amdgpu_connector *amdgpu_connector) { - u8 val; + u8 val = 0; if (!amdgpu_connector->router.ddc_valid) return; -- 2.30.2