All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Lazar, Lijo" <lijo.lazar@amd.com>
To: "Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"Alex Deucher" <alexdeucher@gmail.com>
Cc: Alexander.Deucher@amd.com, amd-gfx@lists.freedesktop.org,
	Hawking.Zhang@amd.com
Subject: Re: [PATCH] drm/amdgpu: Fix uninitialized return value
Date: Tue, 28 Nov 2023 15:19:07 +0530	[thread overview]
Message-ID: <a61886fc-358c-4f89-961d-8145f70d31ee@amd.com> (raw)
In-Reply-To: <1c1877d8-c062-4648-950b-4e05f568b356@gmail.com>


On 11/28/2023 3:07 PM, Christian König wrote:
> Am 27.11.23 um 22:55 schrieb Alex Deucher:
>> On Mon, Nov 27, 2023 at 2:22 PM Christian König
>> <ckoenig.leichtzumerken@gmail.com> wrote:
>>> Am 27.11.23 um 19:29 schrieb Lijo Lazar:
>>>> The return value is uniinitialized if ras context is NULL.
>>>>
>>>> Fixes: 0f4c8faa043c (drm/amdgpu: Move mca debug mode decision to ras)
>>>>
>>>> Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
>>>> ---
>>>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
>>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
>>>> index 1a8668a63e67..f6b47ebce9d6 100644
>>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
>>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
>>>> @@ -3410,7 +3410,7 @@ int amdgpu_ras_reset_gpu(struct amdgpu_device 
>>>> *adev)
>>>>    int amdgpu_ras_set_mca_debug_mode(struct amdgpu_device *adev, 
>>>> bool enable)
>>>>    {
>>>>        struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
>>>> -     int ret;
>>>> +     int ret = 0;
>>> That's usually considered very bad coding style and complained about by
>>> automated checkers.
>>>
>>> Instead explicitly set the return value in the code paths not actually
>>> setting it.
>> In this case, the function is so short, I think it makes things less
>> readable to do that.
>
> Yeah, indeed but that doesn't help us with the coding style checkers.

Are these checkers for real? I see many instances of variable 
initialization including in core kernel code (ex: workqueue) code.

Thanks

Lijo

>
> We could do something like this instead:
>
> if (!con)
>     return 0;
>
> ret = amdgpu_mca_smu_set_debug_mode(adev, enable);
> ...
>
> Regards,
> Christian.
>
>>
>> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>>
>>> Regards,
>>> Christian.
>>>
>>>>        if (con) {
>>>>                ret = amdgpu_mca_smu_set_debug_mode(adev, enable);
>

  reply	other threads:[~2023-11-28  9:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-27 18:29 [PATCH] drm/amdgpu: Fix uninitialized return value Lijo Lazar
2023-11-27 18:46 ` Christian König
2023-11-27 21:55   ` Alex Deucher
2023-11-28  9:37     ` Christian König
2023-11-28  9:49       ` Lazar, Lijo [this message]
2023-11-28 13:18         ` Christian König
2023-11-28 15:00           ` Felix Kuehling
  -- strict thread matches above, loose matches on Subject: below --
2021-05-11 17:25 [PATCH] drm/amdgpu: fix " ts8060
2021-05-11 18:13 ` Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a61886fc-358c-4f89-961d-8145f70d31ee@amd.com \
    --to=lijo.lazar@amd.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Hawking.Zhang@amd.com \
    --cc=alexdeucher@gmail.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.