Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: fix handling order in scheduler CS

We need to clear parser.ibs and num_ibs before amd_sched_fence_create,
otherwise the IB could be freed twice if fence creates fails.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Chunming Zhou <david1.zhou@amd.com>

authored by

Christian König and committed by
Alex Deucher
5d82730a e2840221

+5 -5
+5 -5
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
··· 858 858 job->base.sched = &ring->sched; 859 859 job->base.s_entity = &parser.ctx->rings[ring->idx].entity; 860 860 job->adev = parser.adev; 861 - job->ibs = parser.ibs; 862 - job->num_ibs = parser.num_ibs; 863 861 job->owner = parser.filp; 864 862 job->free_job = amdgpu_cs_free_job; 863 + 864 + job->ibs = parser.ibs; 865 + job->num_ibs = parser.num_ibs; 866 + parser.ibs = NULL; 867 + parser.num_ibs = 0; 865 868 866 869 if (job->ibs[job->num_ibs - 1].user) { 867 870 job->uf = parser.uf; ··· 886 883 cs->out.handle = amdgpu_ctx_add_fence(parser.ctx, ring, 887 884 &fence->base); 888 885 job->ibs[job->num_ibs - 1].sequence = cs->out.handle; 889 - 890 - parser.ibs = NULL; 891 - parser.num_ibs = 0; 892 886 893 887 trace_amdgpu_cs_ioctl(job); 894 888 amd_sched_entity_push_job(&job->base);