The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Bernard Zhao <bernard@vivo.com>,
	dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org,
	linux-arm-msm@vger.kernel.org, opensource.kernel@vivo.com
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@linux.ie>,
	Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>
Subject: Re: [PATCH] drm/msm: Improve exception handling in msm_gpu_crashstate_capture()
Date: Fri, 12 Jun 2020 09:36:09 +0200	[thread overview]
Message-ID: <56a615b6-9881-ff01-fa0f-8ea070fc03e7@web.de> (raw)

> Function msm_gpu_crashstate_capture maybe called for several
> times, and then the state->bos is a potential memleak. Also
> the state->pos maybe alloc failed, but now without any handle.
> This change is to fix some potential memleak and add error
> handle when alloc failed.

I suggest to improve the provided information.
How do you think about a wording variant like the following?

   The function “msm_gpu_crashstate_capture” can be called multiple times.
   The members “comm”, “cmd” and “bos” of the data structure “msm_gpu_state”
   are reassigned with pointers according to dynamic memory allocations
   if the preprocessor symbol “CONFIG_DEV_COREDUMP” was defined.
   But the function “kfree” was not called for them before.

   Thus add missing actions.
   * Release previous objects.
   * Use further null pointer checks.
   * Complete the corresponding exception handling.


Would you like to add the tag “Fixes” to the commit message?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=b791d1bdf9212d944d749a5c7ff6febdba241771#n183> +++ b/drivers/gpu/drm/msm/msm_gpu.c
> @@ -366,8 +366,11 @@  static void msm_gpu_crashstate_capture(struct msm_gpu *gpu,
>  			if (!should_dump(submit, submit->cmd[i].idx))
>  				nr++;
>
> +		kfree(state->bos);
>  		state->bos = kcalloc(nr,
>  			sizeof(struct msm_gpu_state_bo), GFP_KERNEL);
> +		if (!state->bos)
> +			return;
…

Will there be a need to reconsider the indentation for function call parameters
in such source files?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?id=b791d1bdf9212d944d749a5c7ff6febdba241771#n93

Regards,
Markus

             reply	other threads:[~2020-06-12  7:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12  7:36 Markus Elfring [this message]
2020-06-12 10:01 ` [PATCH] drm/msm: Improve exception handling in msm_gpu_crashstate_capture() Greg KH

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=56a615b6-9881-ff01-fa0f-8ea070fc03e7@web.de \
    --to=markus.elfring@web.de \
    --cc=airlied@linux.ie \
    --cc=bernard@vivo.com \
    --cc=daniel@ffwll.ch \
    --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=opensource.kernel@vivo.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