Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp799935pxb; Thu, 17 Feb 2022 15:14:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJyoXv2VgHZ6Bd5fZuSMr17k+PhdYs7Dw5FZ3mq8HVEFWScZ5Au6Egh9SG1yD4Nam0zaXPKz X-Received: by 2002:a17:903:124a:b0:14f:1f26:a71d with SMTP id u10-20020a170903124a00b0014f1f26a71dmr4848547plh.30.1645139690051; Thu, 17 Feb 2022 15:14:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645139690; cv=none; d=google.com; s=arc-20160816; b=HC0Vglz0GdWhqumg0kx8/jh98fYw7ZaJVL/O9CPvShwHCluhZRsFdEUx2yI1JRk7A4 q6/c8z9L56xbyZkCGOnUecpnNFFoS+klCEpguObLyaZzQGfZm+3JEtB86K9pkjsWU701 /t7k74KUDp1ZSlvpQse2fpZjgS1V+4pAQ4Fk8briZ1MX7RYnY8HRfMmkHvYgSZImXAOf uMBC6M+54BaI1+kivofzFZd5dE+VCIncqHfjAo0quP2ld5gw4KMq9b+GmjtBem1fXAGZ K+6LUUPqyMbJ7Dq3dZRlRwUCXrEPNrPxL2Vr1sMqW0DKp1plyK/xD/fSnkPJH2+gHBi3 m1aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ytu0Gx4Ee/+5dkAxsCITxVC/7yyCoOiEqzDXQO8bwEE=; b=CarT/iLZhs0VaFfHIrt1/dhJsSjvDF9A3Wje5RYt56hi4Q3JzCUYtOZS8e0caE1aX4 48lq7LmMYwJ66HxG/zRF2eeAAvJTC+HGDXeqfR2IJEJokhQHMxv9B15tvvseDbbyH9Nr modYxyrSYs9AsALDCIDVWDp+YfF6m96NYRd9uf5r5+4IozkVk45bhrQOh0vxwDsp5+yQ +QRi0HR4XYi5meP4hi2YgxCNJuGaclEQNhSGyi+XzOK7NEzxhORs6TyHko5O2Q1TGVhD ouqA4IrsY3PKLPtJtDSBecRM0JScZ3FJ8VkkFPQWKgDgzrA4lxkpApajx0EJgWf+uSXk P8cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hW00c6RO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m18si1885390pjz.179.2022.02.17.15.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:14:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hW00c6RO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3FD0D2B73C1; Thu, 17 Feb 2022 15:05:37 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243048AbiBQQQr (ORCPT + 99 others); Thu, 17 Feb 2022 11:16:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242892AbiBQQQp (ORCPT ); Thu, 17 Feb 2022 11:16:45 -0500 Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E71FF63EF for ; Thu, 17 Feb 2022 08:16:25 -0800 (PST) Received: by mail-oi1-x232.google.com with SMTP id p15so131561oip.3 for ; Thu, 17 Feb 2022 08:16:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ytu0Gx4Ee/+5dkAxsCITxVC/7yyCoOiEqzDXQO8bwEE=; b=hW00c6ROWmn+snifswDQ5zvWgLKzzxTtorrsLYKzTPfbkWCSd8nyY5XFmOjZtuo6aT Kb0uJN4PiZPTx5bTQss59vSLEEKuDJNp0vp0AntkMIY+3uwLlIUrtLWF08DmkLa+pL0D PYt+YrKPtMIBECkSHxbiHGZCLRem4t6yfvaZlP30y8DUrl2+a4DZPydmZaG156nI43gq HHHmphpOUhIW41BwTVq6fSGOy9RX3CCGX2cGAhzE6dNSOFxz4RiDWTAyZ0a9ADCQCgjP FsIjuJjChETAP8qXmGZGN4GbfLSwe6lsutCPAs7zv3Qig/epukDh/XeewpqjoaUIxsSo OmiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ytu0Gx4Ee/+5dkAxsCITxVC/7yyCoOiEqzDXQO8bwEE=; b=blhn4OB6+at8DW0if6hdBFQqMaVSp8sPwxrUGgxjhUj+7bnP61xUtPV3MdX2ltKfbP vD0uJYdctOyElSW3fqrhny53hIUSqBVYfQ1XkH4bqBnQXBab7kTNLgmrTV8kvPSRWPX2 dFJylVjohXtWU/d/uzmAnix+POdXenQiolnCYpQwMan1Qr0FgFS4Pnbr0voQTcTzNasu ucjmcITTgImdTb6nheDJy/+tIwAR36jOPCFP5DWaGdBDlkS6gfDZUluBpkO9c4Tn6OYz fyv2av2TmusDeQvw10qev/jYOVyhdEUKge9BPsTi3+5bLCE/uKxurqYZVUcRly3GNb1v 2hMQ== X-Gm-Message-State: AOAM532oyYysNZzz/7V5FUBaFt8T8xKvuN3OfxPISo+OMZtOJhNrIKrz 2JJm3O6gTxD3h+/ToLgxrpsp9hiJKFRvccGHmQ4= X-Received: by 2002:aca:ab4c:0:b0:2d4:7c7d:606e with SMTP id u73-20020acaab4c000000b002d47c7d606emr1147310oie.132.1645114585339; Thu, 17 Feb 2022 08:16:25 -0800 (PST) MIME-Version: 1.0 References: <20220217153842.3252424-1-trix@redhat.com> <51018469-3bab-e56d-7407-b16170b5d74c@amd.com> In-Reply-To: <51018469-3bab-e56d-7407-b16170b5d74c@amd.com> From: Alex Deucher Date: Thu, 17 Feb 2022 11:16:14 -0500 Message-ID: Subject: Re: [PATCH] drm/amdgpu: fix amdgpu_ras_block_late_init error handler To: Luben Tuikov Cc: Tom Rix , "Deucher, Alexander" , Christian Koenig , xinhui pan , Dave Airlie , Daniel Vetter , Nathan Chancellor , Nick Desaulniers , Hawking Zhang , John Clements , Tao Zhou , "Chai, Thomas" , "Stanley.Yang" , Dennis Li , "Joshi, Mukul" , Nirmoy Das , llvm@lists.linux.dev, Maling list - DRI developers , amd-gfx list , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,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 Applied. Thanks! Alex On Thu, Feb 17, 2022 at 10:57 AM Luben Tuikov wrote: > > Thanks for catching this. > > Reviewed-by: Luben Tuikov > > Regards, > Luben > > On 2022-02-17 10:38, trix@redhat.com wrote: > > From: Tom Rix > > > > Clang build fails with > > amdgpu_ras.c:2416:7: error: variable 'ras_obj' is used uninitialized > > whenever 'if' condition is true > > if (adev->in_suspend || amdgpu_in_reset(adev)) { > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > amdgpu_ras.c:2453:6: note: uninitialized use occurs here > > if (ras_obj->ras_cb) > > ^~~~~~~ > > > > There is a logic error in the error handler's labels. > > ex/ The sysfs: is the last goto label in the normal code but > > is the middle of error handler. Rework the error handler. > > > > cleanup: is the first error, so it's handler should be last. > > > > interrupt: is the second error, it's handler is next. interrupt: > > handles the failure of amdgpu_ras_interrupt_add_hander() by > > calling amdgpu_ras_interrupt_remove_handler(). This is wrong, > > remove() assumes the interrupt has been setup, not torn down by > > add(). Change the goto label to cleanup. > > > > sysfs is the last error, it's handler should be first. sysfs: > > handles the failure of amdgpu_ras_sysfs_create() by calling > > amdgpu_ras_sysfs_remove(). But when the create() fails there > > is nothing added so there is nothing to remove. This error > > handler is not needed. Remove the error handler and change > > goto label to interrupt. > > > > Fixes: b293e891b057 ("drm/amdgpu: add helper function to do common ras_late_init/fini (v3)") > > Signed-off-by: Tom Rix > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 11 +++++------ > > 1 file changed, 5 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > > index b5cd21cb6e58..c5c8a666110f 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c > > @@ -2432,12 +2432,12 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev, > > if (ras_obj->ras_cb) { > > r = amdgpu_ras_interrupt_add_handler(adev, ras_block); > > if (r) > > - goto interrupt; > > + goto cleanup; > > } > > > > r = amdgpu_ras_sysfs_create(adev, ras_block); > > if (r) > > - goto sysfs; > > + goto interrupt; > > > > /* Those are the cached values at init. > > */ > > @@ -2447,12 +2447,11 @@ int amdgpu_ras_block_late_init(struct amdgpu_device *adev, > > } > > > > return 0; > > -cleanup: > > - amdgpu_ras_sysfs_remove(adev, ras_block); > > -sysfs: > > + > > +interrupt: > > if (ras_obj->ras_cb) > > amdgpu_ras_interrupt_remove_handler(adev, ras_block); > > -interrupt: > > +cleanup: > > amdgpu_ras_feature_enable(adev, ras_block, 0); > > return r; > > } >