Skip to content

Commit e5767a9

Browse files
committed
Merge tag 'drm-misc-next-fixes-2024-01-19' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
A null pointer dereference fix for v3d and a protection fault fix for ttm. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <mripard@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/5zrphn2nhxnwillxlmo6ap3zh7qjt3jgydlm5sntuc4fzvwhpo@hznprx2bjyi7
2 parents b8c6834 + 1f1626a commit e5767a9

2 files changed

Lines changed: 35 additions & 9 deletions

File tree

drivers/gpu/drm/ttm/ttm_device.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func
195195
bool use_dma_alloc, bool use_dma32)
196196
{
197197
struct ttm_global *glob = &ttm_glob;
198-
int ret;
198+
int ret, nid;
199199

200200
if (WARN_ON(vma_manager == NULL))
201201
return -EINVAL;
@@ -215,7 +215,12 @@ int ttm_device_init(struct ttm_device *bdev, const struct ttm_device_funcs *func
215215

216216
ttm_sys_man_init(bdev);
217217

218-
ttm_pool_init(&bdev->pool, dev, dev_to_node(dev), use_dma_alloc, use_dma32);
218+
if (dev)
219+
nid = dev_to_node(dev);
220+
else
221+
nid = NUMA_NO_NODE;
222+
223+
ttm_pool_init(&bdev->pool, dev, nid, use_dma_alloc, use_dma32);
219224

220225
bdev->vma_manager = vma_manager;
221226
spin_lock_init(&bdev->lru_lock);

drivers/gpu/drm/v3d/v3d_submit.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ v3d_job_allocate(void **container, size_t size)
147147
return 0;
148148
}
149149

150+
static void
151+
v3d_job_deallocate(void **container)
152+
{
153+
kfree(*container);
154+
*container = NULL;
155+
}
156+
150157
static int
151158
v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
152159
struct v3d_job *job, void (*free)(struct kref *ref),
@@ -273,17 +280,21 @@ v3d_setup_csd_jobs_and_bos(struct drm_file *file_priv,
273280

274281
ret = v3d_job_init(v3d, file_priv, &(*job)->base,
275282
v3d_job_free, args->in_sync, se, V3D_CSD);
276-
if (ret)
283+
if (ret) {
284+
v3d_job_deallocate((void *)job);
277285
return ret;
286+
}
278287

279288
ret = v3d_job_allocate((void *)clean_job, sizeof(**clean_job));
280289
if (ret)
281290
return ret;
282291

283292
ret = v3d_job_init(v3d, file_priv, *clean_job,
284293
v3d_job_free, 0, NULL, V3D_CACHE_CLEAN);
285-
if (ret)
294+
if (ret) {
295+
v3d_job_deallocate((void *)clean_job);
286296
return ret;
297+
}
287298

288299
(*job)->args = *args;
289300

@@ -860,8 +871,10 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
860871

861872
ret = v3d_job_init(v3d, file_priv, &render->base,
862873
v3d_render_job_free, args->in_sync_rcl, &se, V3D_RENDER);
863-
if (ret)
874+
if (ret) {
875+
v3d_job_deallocate((void *)&render);
864876
goto fail;
877+
}
865878

866879
render->start = args->rcl_start;
867880
render->end = args->rcl_end;
@@ -874,8 +887,10 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
874887

875888
ret = v3d_job_init(v3d, file_priv, &bin->base,
876889
v3d_job_free, args->in_sync_bcl, &se, V3D_BIN);
877-
if (ret)
890+
if (ret) {
891+
v3d_job_deallocate((void *)&bin);
878892
goto fail;
893+
}
879894

880895
bin->start = args->bcl_start;
881896
bin->end = args->bcl_end;
@@ -892,8 +907,10 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data,
892907

893908
ret = v3d_job_init(v3d, file_priv, clean_job,
894909
v3d_job_free, 0, NULL, V3D_CACHE_CLEAN);
895-
if (ret)
910+
if (ret) {
911+
v3d_job_deallocate((void *)&clean_job);
896912
goto fail;
913+
}
897914

898915
last_job = clean_job;
899916
} else {
@@ -1015,8 +1032,10 @@ v3d_submit_tfu_ioctl(struct drm_device *dev, void *data,
10151032

10161033
ret = v3d_job_init(v3d, file_priv, &job->base,
10171034
v3d_job_free, args->in_sync, &se, V3D_TFU);
1018-
if (ret)
1035+
if (ret) {
1036+
v3d_job_deallocate((void *)&job);
10191037
goto fail;
1038+
}
10201039

10211040
job->base.bo = kcalloc(ARRAY_SIZE(args->bo_handles),
10221041
sizeof(*job->base.bo), GFP_KERNEL);
@@ -1233,8 +1252,10 @@ v3d_submit_cpu_ioctl(struct drm_device *dev, void *data,
12331252

12341253
ret = v3d_job_init(v3d, file_priv, &cpu_job->base,
12351254
v3d_job_free, 0, &se, V3D_CPU);
1236-
if (ret)
1255+
if (ret) {
1256+
v3d_job_deallocate((void *)&cpu_job);
12371257
goto fail;
1258+
}
12381259

12391260
clean_job = cpu_job->indirect_csd.clean_job;
12401261
csd_job = cpu_job->indirect_csd.job;

0 commit comments

Comments
 (0)