diff options
author | Markus Elfring <Markus.Elfring@web.de> | 2023-04-16 08:45:54 +0300 |
---|---|---|
committer | Karol Herbst <kherbst@redhat.com> | 2023-04-17 20:08:03 +0300 |
commit | 41239aa4f751fbc39481a4af726faa347a26da83 (patch) | |
tree | aa15e280d142cf87b5edc80dc5c3954b081590fc | |
parent | 5149545dbcbb15105312014201b9c0aa859c6044 (diff) | |
download | linux-41239aa4f751fbc39481a4af726faa347a26da83.tar.xz |
drm/nouveau/clk: Move a variable assignment behind a null pointer check in nvkm_pstate_new()
The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the function “nvkm_pstate_new”.
Thus avoid the risk for undefined behaviour by moving the assignment
for the variable “cstate” 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/6435d829-2c9b-a3f7-c8cd-cf923508a092@web.de
-rw-r--r-- | drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c index da07a2fbef06..178dc56909c2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c @@ -417,7 +417,6 @@ nvkm_pstate_new(struct nvkm_clk *clk, int idx) return 0; pstate = kzalloc(sizeof(*pstate), GFP_KERNEL); - cstate = &pstate->base; if (!pstate) return -ENOMEM; @@ -427,6 +426,7 @@ nvkm_pstate_new(struct nvkm_clk *clk, int idx) pstate->fanspeed = perfE.fanspeed; pstate->pcie_speed = perfE.pcie_speed; pstate->pcie_width = perfE.pcie_width; + cstate = &pstate->base; cstate->voltage = perfE.voltage; cstate->domain[nv_clk_src_core] = perfE.core; cstate->domain[nv_clk_src_shader] = perfE.shader; |