mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-26 04:25:27 +08:00
drm/nouveau/pm: fix a potential race condition when creating an engine context
There is always the possiblity that the ppm->context pointer would get partially updated and accidentally would equal ctx. This would allow two contexts to co-exist, which is not acceptable. Moving the test to the critical section takes care of this problem. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Signed-off-by: Martin Peres <martin.peres@free.fr> Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
This commit is contained in:
parent
3693d54405
commit
305c1959ea
@ -358,12 +358,11 @@ nvkm_perfctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
|
||||
mutex_lock(&nv_subdev(ppm)->mutex);
|
||||
if (ppm->context == NULL)
|
||||
ppm->context = ctx;
|
||||
if (ctx != ppm->context)
|
||||
ret = -EBUSY;
|
||||
mutex_unlock(&nv_subdev(ppm)->mutex);
|
||||
|
||||
if (ctx != ppm->context)
|
||||
return -EBUSY;
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct nvkm_oclass
|
||||
|
Loading…
Reference in New Issue
Block a user