提交 305c1959 编写于 作者: S Samuel Pitoiset 提交者: Ben Skeggs

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: NSamuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: NMartin Peres <martin.peres@free.fr>
Signed-off-by: NBen Skeggs <bskeggs@redhat.com>
上级 3693d544
...@@ -358,12 +358,11 @@ nvkm_perfctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine, ...@@ -358,12 +358,11 @@ nvkm_perfctx_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
mutex_lock(&nv_subdev(ppm)->mutex); mutex_lock(&nv_subdev(ppm)->mutex);
if (ppm->context == NULL) if (ppm->context == NULL)
ppm->context = ctx; ppm->context = ctx;
mutex_unlock(&nv_subdev(ppm)->mutex);
if (ctx != ppm->context) if (ctx != ppm->context)
return -EBUSY; ret = -EBUSY;
mutex_unlock(&nv_subdev(ppm)->mutex);
return 0; return ret;
} }
struct nvkm_oclass struct nvkm_oclass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册