dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tomeu Vizoso <tomeu@tomeuvizoso.net>
To: Brigham Campbell <me@brighamcampbell.com>
Cc: Oded Gabbay <ogabbay@kernel.org>,
	dri-devel@lists.freedesktop.org,  linux-kernel@vger.kernel.org,
	kernel test robot <lkp@intel.com>,
	 Julia Lawall <julia.lawall@inria.fr>
Subject: Re: [PATCH] accel/rocket: Fix usages of kfree() and sizeof()
Date: Mon, 1 Sep 2025 17:43:48 +0200	[thread overview]
Message-ID: <CAAObsKCcpLheLP-qAW34CfG53vGnAceAOT19VUDLt4nKW1tDUA@mail.gmail.com> (raw)
In-Reply-To: <20250813-rocket-free-fix-v1-1-51f00a7a1271@brighamcampbell.com>

On Wed, Aug 13, 2025 at 6:02 PM Brigham Campbell <me@brighamcampbell.com> wrote:
>
> Replace usages of kfree() with kvfree() for pointers which were
> allocated using kvmalloc(), as required by the kernel memory management
> API.
>
> Use sizeof() on the type that a pointer references instead of the
> pointer itself. In this case, scheds and *scheds both happen to be
> pointers, so sizeof() will expand to the same value in either case, but
> using *scheds is more technically correct since scheds is an array of
> drm_gpu_scheduler *.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@inria.fr>
> Closes: https://lore.kernel.org/r/202508120730.PLbjlKbI-lkp@intel.com/
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>

Thanks, Brigham, I just went ahead and applied it to drm-misc-next. I
also think two commits wouldn't have been worth it.

Regards,

Tomeu

> ---
>  drivers/accel/rocket/rocket_job.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/accel/rocket/rocket_job.c b/drivers/accel/rocket/rocket_job.c
> index 5d4afd69230623215e3105da7153d2d010636d52..f6fe1a6d9264b7508a3adc03248e5a704c68c4f0 100644
> --- a/drivers/accel/rocket/rocket_job.c
> +++ b/drivers/accel/rocket/rocket_job.c
> @@ -222,7 +222,7 @@ static int rocket_job_push(struct rocket_job *job)
>  err_unlock:
>         drm_gem_unlock_reservations(bos, job->in_bo_count + job->out_bo_count, &acquire_ctx);
>  err:
> -       kfree(bos);
> +       kvfree(bos);
>
>         return ret;
>  }
> @@ -496,7 +496,8 @@ void rocket_job_fini(struct rocket_core *core)
>  int rocket_job_open(struct rocket_file_priv *rocket_priv)
>  {
>         struct rocket_device *rdev = rocket_priv->rdev;
> -       struct drm_gpu_scheduler **scheds = kmalloc_array(rdev->num_cores, sizeof(scheds),
> +       struct drm_gpu_scheduler **scheds = kmalloc_array(rdev->num_cores,
> +                                                         sizeof(*scheds),
>                                                           GFP_KERNEL);
>         unsigned int core;
>         int ret;
> @@ -630,7 +631,7 @@ int rocket_ioctl_submit(struct drm_device *dev, void *data, struct drm_file *fil
>                 rocket_ioctl_submit_job(dev, file, &jobs[i]);
>
>  exit:
> -       kfree(jobs);
> +       kvfree(jobs);
>
>         return ret;
>  }
>
> ---
> base-commit: a3daf184bd85d7c08ce948a79bb0e4cac2203923
> change-id: 20250813-rocket-free-fix-3ca6a759a290
>
> Thanks!
> Brigham Campbell <me@brighamcampbell.com>
>

      parent reply	other threads:[~2025-09-01 15:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 16:02 [PATCH] accel/rocket: Fix usages of kfree() and sizeof() Brigham Campbell
2025-08-13 17:56 ` Markus Elfring
2025-08-14  3:56   ` Brigham Campbell
2025-08-14  6:19     ` Markus Elfring
2025-09-01 15:43 ` Tomeu Vizoso [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=CAAObsKCcpLheLP-qAW34CfG53vGnAceAOT19VUDLt4nKW1tDUA@mail.gmail.com \
    --to=tomeu@tomeuvizoso.net \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=julia.lawall@inria.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=me@brighamcampbell.com \
    --cc=ogabbay@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).