Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Kunwu Chan <chentao@kylinos.cn>,
	freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-arm-msm@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/msm/adreno: Add a null pointer check in zap_shader_load_mdt()
Date: Thu, 18 Jan 2024 09:06:50 +0100	[thread overview]
Message-ID: <efc748d7-1a67-476a-82a4-206a9ed252cb@web.de> (raw)
In-Reply-To: <4d4f4ae4-e5e9-4d9e-ac25-d262e7ea23fc@kylinos.cn>

>>> kasprintf() returns a pointer to dynamically allocated memory
>>> which can be NULL upon failure. Ensure the allocation was successful
>>> by checking the pointer validity.
>> …
>>> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
>>> @@ -144,6 +144,10 @@ static int zap_shader_load_mdt(struct msm_gpu *gpu, const char *fwname,
>>>           char *newname;
>>>
>>>           newname = kasprintf(GFP_KERNEL, "qcom/%s", fwname);
>>> +        if (!newname) {
>>> +            ret = -ENOMEM;
>>> +            goto out;
>>> +        }
>> …
>>
>> How do you think about to avoid the repetition of the pointer check
>> for the variable “mem_region”?
> "mem_region"? Is this a clerical error, do you mean 'newname'?

Please take another look at implementation details:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/drm/msm/adreno/adreno_gpu.c?h=v6.7#n124>> Can the usage of other labels become more appropriate?

I propose to reconsider also the influence of the label “out” here.
https://elixir.bootlin.com/linux/v6.7/source/drivers/gpu/drm/msm/adreno/adreno_gpu.c#L167

Regards,
Markus

      reply	other threads:[~2024-01-18  8:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16  3:27 [PATCH] drm/msm/adreno: Add a null pointer check to the zap_shader_load_mdt Kunwu Chan
2024-01-17 18:50 ` [PATCH] drm/msm/adreno: Add a null pointer check in zap_shader_load_mdt() Markus Elfring
2024-01-18  2:16   ` Kunwu Chan
2024-01-18  8:06     ` Markus Elfring [this message]

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=efc748d7-1a67-476a-82a4-206a9ed252cb@web.de \
    --to=markus.elfring@web.de \
    --cc=airlied@gmail.com \
    --cc=chentao@kylinos.cn \
    --cc=daniel@ffwll.ch \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=sean@poorly.run \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox