From: Markus Elfring <Markus.Elfring@web.de>
To: kernel-janitors@vger.kernel.org, nouveau@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, Ben Skeggs <bskeggs@redhat.com>,
Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>,
Karol Herbst <kherbst@redhat.com>, Lyude Paul <lyude@redhat.com>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: [Nouveau] [PATCH 7/9] drm/nouveau/pci: Move a variable assignment behind condition checks in nvkm_pcie_set_link()
Date: Sun, 16 Apr 2023 11:46:32 +0200 [thread overview]
Message-ID: <b31019b1-bb73-ed93-3378-e551e17a4f32@web.de> (raw)
In-Reply-To: <2a746461-844a-2ad6-7b52-03f13fe1b9bf@web.de>
Date: Sun, 16 Apr 2023 08:18:40 +0200
The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the function “nvkm_pcie_set_link”.
Thus avoid the risk for undefined behaviour by moving the assignment
for the variable “subdev” behind some condition checks.
This issue was detected by using the Coccinelle software.
Fixes: bcc19d9bf5cd8d49428c487adced1aa101271b18 ("drm/nouveau/pci: implement generic code for pcie speed change")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c
index d71e5db5028a..b295f100e1c1 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/pcie.c
@@ -114,7 +114,7 @@ nvkm_pcie_init(struct nvkm_pci *pci)
int
nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
{
- struct nvkm_subdev *subdev = &pci->subdev;
+ struct nvkm_subdev *subdev;
enum nvkm_pcie_speed cur_speed, max_speed;
struct pci_bus *pbus;
int ret;
@@ -126,6 +126,7 @@ nvkm_pcie_set_link(struct nvkm_pci *pci, enum nvkm_pcie_speed speed, u8 width)
if (!pci->func->pcie.set_link)
return -ENOSYS;
+ subdev = &pci->subdev;
nvkm_trace(subdev, "requested %s\n", nvkm_pcie_speeds[speed]);
if (pci->func->pcie.version(pci) < 2) {
--
2.40.0
next prev parent reply other threads:[~2023-04-16 9:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <40c60719-4bfe-b1a4-ead7-724b84637f55@web.de>
[not found] ` <1a11455f-ab57-dce0-1677-6beb8492a257@web.de>
2023-04-16 9:30 ` [Nouveau] [PATCH 0/9] GPU-DRM-nouveau: Adjustments for seven function implementations Markus Elfring
2023-04-16 9:33 ` [Nouveau] [PATCH 1/9] drm/nouveau/debugfs: Move an expression into a function call parameter in nouveau_debugfs_pstate_set() Markus Elfring
2023-04-16 9:36 ` [Nouveau] [PATCH 2/9] drm/nouveau/debugfs: Move a variable assignment behind a null pointer check in nouveau_debugfs_pstate_get() Markus Elfring
2023-04-16 9:38 ` [Nouveau] [PATCH 3/9] drm/nouveau/debugfs: Use seq_putc() " Markus Elfring
2023-04-16 9:40 ` [Nouveau] [PATCH 4/9] drm/nouveau/debugfs: Replace five seq_printf() calls by seq_puts() " Markus Elfring
2023-04-16 9:42 ` [Nouveau] [PATCH 5/9] drm/nouveau/bios/power_budget: Move an expression into a macro call parameter in nvbios_power_budget_header() Markus Elfring
2023-04-16 9:44 ` [Nouveau] [PATCH 6/9] drm/nouveau/clk: Move a variable assignment behind a null pointer check in nvkm_pstate_new() Markus Elfring
2023-04-16 9:46 ` Markus Elfring [this message]
2023-04-16 9:54 ` [Nouveau] [PATCH 8/9] drm/nouveau/pci: Move an expression into a function call parameter in nvkm_pcie_set_link() Markus Elfring
2023-04-16 9:56 ` [Nouveau] [PATCH 9/9] drm/nouveau/therm: Move an assignment statement behind a null pointer check in two functions Markus Elfring
2023-04-17 16:25 ` [Nouveau] [PATCH 0/9] GPU-DRM-nouveau: Adjustments for seven function implementations Karol Herbst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b31019b1-bb73-ed93-3378-e551e17a4f32@web.de \
--to=markus.elfring@web.de \
--cc=airlied@gmail.com \
--cc=bskeggs@redhat.com \
--cc=cocci@inria.fr \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kherbst@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox