Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp542314pxb; Thu, 9 Sep 2021 06:47:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysRZsymsgrkQNFBoadO8jqAKPjKQ7WEiPLQ3DRLkw8eKW+6zWe7kjCJLrzxXUxkTDiwbK2 X-Received: by 2002:a02:caaf:: with SMTP id e15mr2951935jap.11.1631195227813; Thu, 09 Sep 2021 06:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631195227; cv=none; d=google.com; s=arc-20160816; b=0yGJcMwY+L8FF1vuCYGyfP70KD3qYf11kxHuvVuCaNIy3xIrpLea0en24LFdYENPNy DoYOkUIKSx7eMXnmYAhOMFAbz6e602emCAt1r8FjLxv9yK8cakTIGUKDOWuvYP1CdCHl kdA+EyKXhoPO8czgC4Uj0uKb4xH8q64ibVZVN91AssV1ZFNWTQU1pPPoqqgc1A2ZHxSU QTUCThu/6laC0qs9wB06RdMEz5moX96nqGC8By/o9tDyYRNycp1CVRGhm+0tmDR93EKI CV5mYFif7gShWVWtIVpyFKxuCb7G2j2lDZ46MKT6k2/MaVgkbAEJhtEkwOsIt8i4grcE 7MEg== 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=j+9vkv6YgDCd9wx4PhcAj9BnXYnleVus01ySJY8l5os=; b=qhxyCC9XQwil6bylWgJlqMnTo2q3srWm0gHGFqLFdaDdVqWutgugzpGUwd8o1z5VKt HQ35ca3lVBxid7LAiB8c5kQSG/F+GAnbSPRSfjzh1s3PAc/TYHDLRKqTVgM4IjJty11R k6XTGZEMw7BeBJUGjGl+g9tjXyHEFyB3Ye4Dzca5mrM7H9/Ws0QEsAb7FM5R9LFq9Jh2 C4ZsogR9U1qVTCFwZz0lQlz5/oKsx/wBjyCtU4/ttZm80bcOn9qwKZH4kjzMVAWcrUYO AKu1TlVVjEck7pb6EIef5t3RLCIUKxOWJ/8eQw+zxd4EmLt6wT7UHhSrjAA1HYwRsE+U sNnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kElG4SBj; 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 z17si1770647ils.47.2021.09.09.06.46.55; Thu, 09 Sep 2021 06:47:07 -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=kElG4SBj; 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 S1354240AbhIINrI (ORCPT + 99 others); Thu, 9 Sep 2021 09:47:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:41082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353736AbhIIMrH (ORCPT ); Thu, 9 Sep 2021 08:47:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D3390630EE; Thu, 9 Sep 2021 11:56:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188586; bh=+UA7cOAeOBiOkWjQPLj3hBk6pksEt7VW9MrjfqOBPX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kElG4SBj/6i8IkJHJUskRsped9jLdZLqpZWsJ1gJHfJa5CTYSUdrS6qFUMWe6ZAhm 4bcNpHZw4chuuHciXT4PuK9qFd+n32V1H9HCJeAkiatsx3lfWw7rwkF2PtYCTMNWVU gyaDGzybXmoxioEbCZEIRcPup6EOITLst8daVJxWGin9oOcizenVSYC0S/Pxl1fKyM YMT7ndq9HsZCo9sLlrp1U7vsNJvOS3exrfGwa5O8VtQKxZY+eM5R9Z+oCp3oqr+ZkR HRzBFituTkpfNNwBXJojw68D51Lmjknuz2Ruumv1e64h8KA8UewO9wZWrWmriUZlis lH6gmA4dCaZYw== 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 5.4 062/109] gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() Date: Thu, 9 Sep 2021 07:54:19 -0400 Message-Id: <20210909115507.147917-62-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-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 70dbe343f51d..89cecdba81ac 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c @@ -339,7 +339,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