Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp451619pxb; Thu, 9 Sep 2021 04:55:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAPDLF90glLOi9vMdsN+4NSHwebgEcbev6mHqT6IPrY2YohDPpfS9DSif8DHLXoS3IV7YP X-Received: by 2002:a6b:f610:: with SMTP id n16mr2375051ioh.139.1631188532816; Thu, 09 Sep 2021 04:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188532; cv=none; d=google.com; s=arc-20160816; b=SaY7n9G8O0dFueGpjt5xY4iYv5sbKUx8GxzyULTN1d/fnlOsmxSuLToBiHJVgc0UUT ZsiUcxjMI2VPXUn/c+pSzI52tNIHjhJKW3PgafqrQBFma6lXHao9K3k84+3oTRCh9rFi 2lO1mO1sfNtKQrkdbefwOJFLPRoffkrfGyGG4adZSnH1FlYMf/mzHl6cM8nMk5cduu6l PjL8tI7nQnQsVgV1Ikr+scy3NGkNe6ZvatS1P6906YIsGrVMnLqoEMUPNMHaA1ZOM/wx IOpY8sU8k0BGyZk8uyzjH1+nP7W6TTh1byFAhDFz2wvhu+d73cuvAk0hmKJt1pQi/pM6 kWaQ== 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=oc5++N+YcrMsd59b1gAiqHTFhVobhMA43W1bGrU2fjc=; b=xo16jww5m6kFOHmsk+mNMcH17ICOqyM3rWOy+RbOyj8Fm/si/S7UDE2yaRYpVYGyLI vnEXKeE9FeDstmWVmoUMkpAPWtYTmumZ+8oCj2UByjOwKMuiQBxnmg3SmlSVfxYFJBf4 eRLLJMA0q83cjKe4kKlhGfRt++MeUYlbUKXenv181VqJqjlznJ09yMWHtzDxGeyEusCv GZoMeTVUQUhPRrUCLPQ+T5EPKjf3JUH8N1OdlIfvr3TR4cC0x55JlaFICPUWyhJyfBbE fFFs2EQwOorpRhyeADVX5PyIkQLBVXrJDQoOHneCs4GDrrPzKF9i0iLFg/WZES9t/9ur YQRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=sqmvIMqS; 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 m82si1290136ioa.74.2021.09.09.04.55.22; Thu, 09 Sep 2021 04:55:32 -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=sqmvIMqS; 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 S241205AbhIILzm (ORCPT + 99 others); Thu, 9 Sep 2021 07:55:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:54742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240464AbhIILwU (ORCPT ); Thu, 9 Sep 2021 07:52:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4170D61374; Thu, 9 Sep 2021 11:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187859; bh=taatuuLuDBoBSsvAWC34YtQ3EAR1kJj2dTPwEIz+LIE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sqmvIMqSnu8towf9gCQL4g3PmBOMQcOf3/7R2cWEdHlUFwMqBMAfaRzvz+mtbFla0 ceSARKFzbo5UAHgY4UaxnyN63t8/0acKbbnmlwj0Lvj26qRFNwLCGvSLQuF7KEKDsp Dii6LbgeQhBkg+GKpyrCf08NAq/2VukOHHItpkDsisD+JdXfPjyU2qPM9tvqirSR5c x6q8e/7Lpv8WxGpbdQUlagOxviKuEhRbjYIKTPVasgwZG/b93PdEo73cIMaRiFTYLC GxB/9BCInor+hGYPYDoACjkBuhScILqyTGMVb3bWGdEDp5KwsnFm3pJgZ/Usu96yA4 +YxJch3hhBt+g== 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.14 147/252] gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port() Date: Thu, 9 Sep 2021 07:39:21 -0400 Message-Id: <20210909114106.141462-147-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-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 bca4dddd5a15..82608df43396 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