* [PATCH] accel/rocket: Fix usages of kfree() and sizeof()
@ 2025-08-13 16:02 Brigham Campbell
2025-08-13 17:56 ` Markus Elfring
2025-09-01 15:43 ` [PATCH] " Tomeu Vizoso
0 siblings, 2 replies; 5+ messages in thread
From: Brigham Campbell @ 2025-08-13 16:02 UTC (permalink / raw)
To: Tomeu Vizoso, Oded Gabbay
Cc: dri-devel, linux-kernel, kernel test robot, Julia Lawall,
Brigham Campbell
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>
---
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>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] accel/rocket: Fix usages of kfree() and sizeof()
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-09-01 15:43 ` [PATCH] " Tomeu Vizoso
1 sibling, 1 reply; 5+ messages in thread
From: Markus Elfring @ 2025-08-13 17:56 UTC (permalink / raw)
To: Brigham Campbell, dri-devel, lkp
Cc: LKML, Julia Lawall, Oded Gabbay, Tomeu Vizoso
> Replace usages of kfree() with kvfree() for pointers which were
> allocated using kvmalloc(), as required by the kernel memory management
> API.
How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc1#n145
> Use sizeof() on the type that a pointer references instead of …
Would it be helpful to offer desirable changes by separate update steps?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc1#n81
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] accel/rocket: Fix usages of kfree() and sizeof()
2025-08-13 17:56 ` Markus Elfring
@ 2025-08-14 3:56 ` Brigham Campbell
2025-08-14 6:19 ` Markus Elfring
0 siblings, 1 reply; 5+ messages in thread
From: Brigham Campbell @ 2025-08-14 3:56 UTC (permalink / raw)
To: Markus Elfring, dri-devel, lkp
Cc: LKML, Julia Lawall, Oded Gabbay, Tomeu Vizoso, dri-devel
On Wed Aug 13, 2025 at 11:56 AM MDT, Markus Elfring wrote:
>> Replace usages of kfree() with kvfree() for pointers which were
>> allocated using kvmalloc(), as required by the kernel memory management
>> API.
>
> How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc1#n145
All issues addressed by this patch were introduced by the following
commit:
Fixes: 0810d5ad88a1 ("accel/rocket: Add job submission IOCTL")
>> Use sizeof() on the type that a pointer references instead of …
>
> Would it be helpful to offer desirable changes by separate update steps?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc1#n81
Tomeu? Oded? Would either of you prefer that I split this patch into two
patches (one to fix kfree()->kvfree() and another to fix sizeof())?
I had considered splitting it into two patches, but the changes were so
minor that I figured it wasn't worth it. Please let me know if you
prefer separate patches and I'll gladly prep another revision.
Thanks,
Brigham
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: accel/rocket: Fix usages of kfree() and sizeof()
2025-08-14 3:56 ` Brigham Campbell
@ 2025-08-14 6:19 ` Markus Elfring
0 siblings, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2025-08-14 6:19 UTC (permalink / raw)
To: Brigham Campbell, dri-devel, lkp, linux-rockchip,
linux-arm-kernel
Cc: LKML, Julia Lawall, Oded Gabbay, Tomeu Vizoso
> I had considered splitting it into two patches, but the changes were so
> minor that I figured it wasn't worth it. Please let me know if you
> prefer separate patches and I'll gladly prep another revision.
You can distinguish mentioned change possibilities better also according to
their severity, can't you?
Regards,
Markus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] accel/rocket: Fix usages of kfree() and sizeof()
2025-08-13 16:02 [PATCH] accel/rocket: Fix usages of kfree() and sizeof() Brigham Campbell
2025-08-13 17:56 ` Markus Elfring
@ 2025-09-01 15:43 ` Tomeu Vizoso
1 sibling, 0 replies; 5+ messages in thread
From: Tomeu Vizoso @ 2025-09-01 15:43 UTC (permalink / raw)
To: Brigham Campbell
Cc: Oded Gabbay, dri-devel, linux-kernel, kernel test robot,
Julia Lawall
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>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-01 15:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH] " Tomeu Vizoso
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).