* [PATCH] drm/tegra: remove no need NULL check before kfree
@ 2021-11-16 1:55 Bernard Zhao
2021-11-16 10:01 ` Mikko Perttunen
0 siblings, 1 reply; 2+ messages in thread
From: Bernard Zhao @ 2021-11-16 1:55 UTC (permalink / raw)
To: Thierry Reding, David Airlie, Daniel Vetter, Jonathan Hunter,
dri-devel, linux-tegra, linux-kernel
Cc: Bernard Zhao
This change is to cleanup the code a bit.
Signed-off-by: Bernard Zhao <bernard@vivo.com>
---
drivers/gpu/drm/tegra/submit.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
index 776f825df52f..c2fc9677742e 100644
--- a/drivers/gpu/drm/tegra/submit.c
+++ b/drivers/gpu/drm/tegra/submit.c
@@ -608,12 +608,10 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
if (job_data && job_data->used_mappings) {
for (i = 0; i < job_data->num_used_mappings; i++)
tegra_drm_mapping_put(job_data->used_mappings[i].mapping);
-
- kfree(job_data->used_mappings);
}
- if (job_data)
- kfree(job_data);
+ kfree(job_data->used_mappings);
+ kfree(job_data);
put_bo:
gather_bo_put(&bo->base);
unlock:
--
2.33.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/tegra: remove no need NULL check before kfree
2021-11-16 1:55 [PATCH] drm/tegra: remove no need NULL check before kfree Bernard Zhao
@ 2021-11-16 10:01 ` Mikko Perttunen
0 siblings, 0 replies; 2+ messages in thread
From: Mikko Perttunen @ 2021-11-16 10:01 UTC (permalink / raw)
To: Bernard Zhao, Thierry Reding, David Airlie, Daniel Vetter,
Jonathan Hunter, dri-devel, linux-tegra, linux-kernel
On 11/16/21 3:55 AM, Bernard Zhao wrote:
> This change is to cleanup the code a bit.
>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
> drivers/gpu/drm/tegra/submit.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/tegra/submit.c b/drivers/gpu/drm/tegra/submit.c
> index 776f825df52f..c2fc9677742e 100644
> --- a/drivers/gpu/drm/tegra/submit.c
> +++ b/drivers/gpu/drm/tegra/submit.c
> @@ -608,12 +608,10 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
> if (job_data && job_data->used_mappings) {
> for (i = 0; i < job_data->num_used_mappings; i++)
> tegra_drm_mapping_put(job_data->used_mappings[i].mapping);
> -
> - kfree(job_data->used_mappings);
> }
>
> - if (job_data)
> - kfree(job_data);
> + kfree(job_data->used_mappings);
Now if job_data == NULL, we dereference a NULL pointer here.
In general I'm not a fan of relying on kfree() etc. being a no-op on
NULL pointers, since doing so gets rid of visual hints on code paths
indicating the "liveness" of pointer variables.
However I'll let Thierry/other maintainers decide according to their
preferences.
Thanks,
Mikko
> + kfree(job_data);
> put_bo:
> gather_bo_put(&bo->base);
> unlock:
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-16 10:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 1:55 [PATCH] drm/tegra: remove no need NULL check before kfree Bernard Zhao
2021-11-16 10:01 ` Mikko Perttunen
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.