Commit e1b570db authored by Markus Elfring's avatar Markus Elfring Committed by Karol Herbst

drm/nouveau/debugfs: Move a variable assignment behind a null pointer check in...

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarKarol Herbst <kherbst@redhat.com>
Signed-off-by: default avatarKarol Herbst <kherbst@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/5b7b99f7-1692-74e5-4b1e-cfa14dad7c57@web.de
parent 3778724b
...@@ -73,13 +73,14 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data) ...@@ -73,13 +73,14 @@ nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
{ {
struct drm_device *drm = m->private; struct drm_device *drm = m->private;
struct nouveau_debugfs *debugfs = nouveau_debugfs(drm); struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
struct nvif_object *ctrl = &debugfs->ctrl; struct nvif_object *ctrl;
struct nvif_control_pstate_info_v0 info = {}; struct nvif_control_pstate_info_v0 info = {};
int ret, i; int ret, i;
if (!debugfs) if (!debugfs)
return -ENODEV; return -ENODEV;
ctrl = &debugfs->ctrl;
ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info)); ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info));
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment