summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau
diff options
context:
space:
mode:
authorMarkus Elfring <Markus.Elfring@web.de>2023-04-15 22:24:43 +0300
committerKarol Herbst <kherbst@redhat.com>2023-04-17 20:08:03 +0300
commite1b570db8687c993e7a87516387a3bb3b5e63ac6 (patch)
tree0b7a56d57c31e396ce19c799f84172190ef4f335 /drivers/gpu/drm/nouveau
parent3778724bec53a3585cde6aed8c75ae3f085c3dcb (diff)
downloadlinux-e1b570db8687c993e7a87516387a3bb3b5e63ac6.tar.xz
drm/nouveau/debugfs: Move a variable assignment behind a null pointer check in nouveau_debugfs_pstate_get()
The address of a data structure member was determined before a corresponding null pointer check in the implementation of the function “nouveau_debugfs_pstate_get”. Thus avoid the risk for undefined behaviour by moving the assignment for the variable “ctrl” behind the null pointer check. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Reviewed-by: Karol Herbst <kherbst@redhat.com> Signed-off-by: Karol Herbst <kherbst@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/5b7b99f7-1692-74e5-4b1e-cfa14dad7c57@web.de
Diffstat (limited to 'drivers/gpu/drm/nouveau')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_debugfs.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_debugfs.c b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
index 44e26b6e74c7..a859a086f308 100644
--- a/drivers/gpu/drm/nouveau/nouveau_debugfs.c
+++ b/drivers/gpu/drm/nouveau/nouveau_debugfs.c
@@ -73,13 +73,14 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
{
struct drm_device *drm = m->private;
struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
- struct nvif_object *ctrl = &debugfs->ctrl;
+ struct nvif_object *ctrl;
struct nvif_control_pstate_info_v0 info = {};
int ret, i;
if (!debugfs)
return -ENODEV;
+ ctrl = &debugfs->ctrl;
ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info));
if (ret)
return ret;