Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp649289rdb; Tue, 31 Oct 2023 19:58:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHivmoKaChUVmswAQ5xtXEC2fDvUH6FLagSCzaoc44OquL1CHIEtW+fI2XtJpiBMZeR90Im X-Received: by 2002:a81:af03:0:b0:5a7:bb95:681c with SMTP id n3-20020a81af03000000b005a7bb95681cmr16924903ywh.36.1698807521139; Tue, 31 Oct 2023 19:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698807521; cv=none; d=google.com; s=arc-20160816; b=NIRrouD+VbQ09Ti5J2Gy0NAVYjfo+X/6iAccmcil3v0z1JdZ1Is+RUU967Oh9Drwka AMVdxvW5M9Q6apERJGWuAKUordrTfjhTfZmNjP+snaoojnmgPD7rsAJh4/ofIOsNnpa4 F3UA2HJVk/QEEHYXrgjeN4K9KraYtrTkh0150F9gleN0gip3BchL6sau3LKeWt1qk10i eKZFfQt2pshqUq6Kr7JUwSfAYB260Lvii+nXX6WgFgJrmnaN65v3VGRsTmSO35kE2MNl UR+nv+9P9rB9ckjeEHO4WJNMcxZy765caddp1M5P+ZTdCw5a3JXJtkUMtxQeAzrpU+6W SMlA== 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 :message-id:date:subject:cc:to:from; bh=1K7HBhVQ82tMtH8tu2Lj/RPJasKhOySM4nIFwxqeH/k=; fh=Hsg0Sacw2fv+6kZ2Ht3cOWhJV6L78KEFU1zdnMSqiZU=; b=zfgd/6Eb1pJs4MFSFhODeusORWXzPDUcrJbaUOGLVpGvmPtPfNcsBCJRpkJUD9dkyy YpGM3Jql32sr6H5364TtEeh3kNesI4YA2rh/cwOLYi4S+7J1Y/PSCsYwPu6HY6EUk+1C 5aStptqRsb/ko3zY/R37pPm0/L7mE3kNs0XRmaBhI4lc4hqT6Zn8bHINwwdaKGKqlvlp BM5+vzC7zl5if3sCEeoQGOmTZdh38rMTRnuU+MywADkHChV2BDilhK4mY4JekAW3Vd6o eQcqQb80pGuPFfgd9medD52fDhgGqjI6EVqjL9LHzFQlhKCPL6djuKuytLguHgwYCr77 rHdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z186-20020a6333c3000000b005b90b310e26si2096587pgz.403.2023.10.31.19.58.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 19:58:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 29E3E80DF24C; Tue, 31 Oct 2023 19:58:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346237AbjKAC6j (ORCPT + 99 others); Tue, 31 Oct 2023 22:58:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345437AbjKAC6i (ORCPT ); Tue, 31 Oct 2023 22:58:38 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 27F2DA4; Tue, 31 Oct 2023 19:58:35 -0700 (PDT) Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id A887A605164A1; Wed, 1 Nov 2023 10:58:04 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch Cc: Su Hui , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] drm/radeon/ni_dpm: add an error code check in ni_dpm_init Date: Wed, 1 Nov 2023 10:57:53 +0800 Message-Id: <20231101025752.988228-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RDNS_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 19:58:40 -0700 (PDT) ni_patch_single_dependency_table_based_on_leakage() return zero or negative error code. But ni_patch_dependency_tables_based_on_leakage() doesn't check the return value of the first function call. It's same for ni_dpm_init(). It's better to add this error code check. Signed-off-by: Su Hui --- drivers/gpu/drm/radeon/ni_dpm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c index 3e1c1a392fb7..f521dc929a06 100644 --- a/drivers/gpu/drm/radeon/ni_dpm.c +++ b/drivers/gpu/drm/radeon/ni_dpm.c @@ -1010,6 +1010,8 @@ static int ni_patch_dependency_tables_based_on_leakage(struct radeon_device *rde ret = ni_patch_single_dependency_table_based_on_leakage(rdev, &rdev->pm.dpm.dyn_state.vddc_dependency_on_sclk); + if (ret) + return ret; ret = ni_patch_single_dependency_table_based_on_leakage(rdev, &rdev->pm.dpm.dyn_state.vddc_dependency_on_mclk); @@ -4098,7 +4100,12 @@ int ni_dpm_init(struct radeon_device *rdev) rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].clk = 72000; rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[3].v = 900; - ni_patch_dependency_tables_based_on_leakage(rdev); + ret = ni_patch_dependency_tables_based_on_leakage(rdev); + if (ret) { + kfree(rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries); + r600_free_extended_power_table(rdev); + return ret; + } if (rdev->pm.dpm.voltage_response_time == 0) rdev->pm.dpm.voltage_response_time = R600_VOLTAGERESPONSETIME_DFLT; -- 2.30.2