drm/tegra: remove no need NULL check before kfree
PATCH 1/1 drm/tegra: remove no need NULL check before kfree
This change is to cleanup the code a bit.
Signed-off-by Bernard Zhao <[email protected]>
--- drivers/gpu/drm/tegra/submit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/tegra/submit.c +2 -4
@@ -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:
Signature · 1 line
2.33.1
Quoted 12 lines · Bernard Zhao
This change is to cleanup the code a bit.
Signed-off-by Bernard Zhao <[email protected]>--- drivers/gpu/drm/tegra/submit.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/gpu/drm/tegra/submit.c +0
-0
drivers/gpu/drm/tegra/submit.c int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, · line 613
Quoted 10 lines
drivers/gpu/drm/tegra/submit.c +1
-4@@ -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
Quoted 5 lines
drivers/gpu/drm/tegra/submit.c +1
-0+kfree (job_data); put_bo:gather_bo_put (&bo->base); unlock: