From: Andrey Shumilin <shum.sdl@nppct.ru>
To: Karol Herbst <kherbst@redhat.com>
Cc: Andrey Shumilin <shum.sdl@nppct.ru>,
Lyude Paul <lyude@redhat.com>, Danilo Krummrich <dakr@redhat.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org, khoroshilov@ispras.ru,
ykarpov@ispras.ru, vmerzlyakov@ispras.ru, vefanov@ispras.ru
Subject: [PATCH] therm.c: Adding an array index check before accessing an element.
Date: Sat, 23 Mar 2024 09:39:33 +0300 [thread overview]
Message-ID: <20240323063933.665695-1-shum.sdl@nppct.ru> (raw)
It is possible to access an element at index -1 if at the
first iteration of the loop the result of switch is equal to 0x25
Added variable checking.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Andrey Shumilin <shum.sdl@nppct.ru>
---
drivers/gpu/drm/nouveau/nvkm/subdev/bios/therm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/therm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/therm.c
index 5babc5a7c7d5..78387053f214 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/therm.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/therm.c
@@ -180,6 +180,8 @@ nvbios_therm_fan_parse(struct nvkm_bios *bios, struct nvbios_therm_fan *fan)
cur_trip->fan_duty = duty_lut[(value & 0xf000) >> 12];
break;
case 0x25:
+ if (fan->nr_fan_trip == 0)
+ fan->nr_fan_trip++;
cur_trip = &fan->trip[fan->nr_fan_trip - 1];
cur_trip->fan_duty = value;
break;
--
2.30.2
next reply other threads:[~2024-03-23 6:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-23 6:39 Andrey Shumilin [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-11-16 6:30 [PATCH] therm.c: Adding an array index check before accessing an element Andrey Shumilin
2024-01-05 13:50 ` Alexey Khoroshilov
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=20240323063933.665695-1-shum.sdl@nppct.ru \
--to=shum.sdl@nppct.ru \
--cc=airlied@gmail.com \
--cc=dakr@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kherbst@redhat.com \
--cc=khoroshilov@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=nouveau@lists.freedesktop.org \
--cc=vefanov@ispras.ru \
--cc=vmerzlyakov@ispras.ru \
--cc=ykarpov@ispras.ru \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).