Skip to content

Commit

Permalink
drm/nouveau/secboot: fix NULL pointer dereference
Browse files Browse the repository at this point in the history
The msgqueue pointer validity should be checked by its owner, not by the
msgqueue code itself to avoid this situation.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Alexandre Courbot authored and Dave Airlie committed Mar 17, 2017
1 parent aa7fc0c commit b7d6c8d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
7 changes: 7 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/engine/sec2/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ static void
nvkm_sec2_recv(struct work_struct *work)
{
struct nvkm_sec2 *sec2 = container_of(work, typeof(*sec2), work);

if (!sec2->queue) {
nvkm_warn(&sec2->engine.subdev,
"recv function called while no firmware set!\n");
return;
}

nvkm_msgqueue_recv(sec2->queue);
}

Expand Down
5 changes: 2 additions & 3 deletions drivers/gpu/drm/nouveau/nvkm/falcon/msgqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,11 +510,10 @@ nvkm_msgqueue_del(struct nvkm_msgqueue **queue)
void
nvkm_msgqueue_recv(struct nvkm_msgqueue *queue)
{
if (!queue || !queue->func || !queue->func->recv) {
if (!queue->func || !queue->func->recv) {
const struct nvkm_subdev *subdev = queue->falcon->owner;

nvkm_warn(subdev,
"cmdqueue recv function called while no firmware set!\n");
nvkm_warn(subdev, "missing msgqueue recv function\n");
return;
}

Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gm20b.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
static void
gm20b_pmu_recv(struct nvkm_pmu *pmu)
{
if (!pmu->queue) {
nvkm_warn(&pmu->subdev,
"recv function called while no firmware set!\n");
return;
}

nvkm_msgqueue_recv(pmu->queue);
}

Expand Down

0 comments on commit b7d6c8d

Please sign in to comment.