From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,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 D7E9DC04A6B for ; Fri, 10 May 2019 10:08:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC3D420881 for ; Fri, 10 May 2019 10:08:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727337AbfEJKIs (ORCPT ); Fri, 10 May 2019 06:08:48 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:39225 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727053AbfEJKIr (ORCPT ); Fri, 10 May 2019 06:08:47 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hP2SJ-00013j-8B; Fri, 10 May 2019 10:08:43 +0000 From: Colin King To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Zhou , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] drm/amdgpu: fix return of an uninitialized value in variable ret Date: Fri, 10 May 2019 11:08:42 +0100 Message-Id: <20190510100842.30458-1-colin.king@canonical.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King In the case where is_enable is false and lo_base_addr is non-zero the variable ret has not been initialized and is being checked for non-zero and potentially garbage is being returned. Fix this by not returning ret but instead returning -EINVAL on the zero lo_base_addr case. Addresses-Coverity: ("Uninitialized scalar variable") Fixes: a6ac0b44bab9 ("drm/amdgpu: add df perfmon regs and funcs for xgmi") Signed-off-by: Colin Ian King --- drivers/gpu/drm/amd/amdgpu/df_v3_6.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c index a5c3558869fb..8c09bf994acd 100644 --- a/drivers/gpu/drm/amd/amdgpu/df_v3_6.c +++ b/drivers/gpu/drm/amd/amdgpu/df_v3_6.c @@ -398,10 +398,7 @@ static int df_v3_6_start_xgmi_link_cntr(struct amdgpu_device *adev, NULL); if (lo_base_addr == 0) - ret = -EINVAL; - - if (ret) - return ret; + return -EINVAL; lo_val = RREG32_PCIE(lo_base_addr); -- 2.20.1