From: Hangyu Hua <hbh25y@gmail.com>
To: bskeggs@redhat.com, kherbst@redhat.com, lyude@redhat.com,
airlied@linux.ie, daniel@ffwll.ch
Cc: nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, Hangyu Hua <hbh25y@gmail.com>
Subject: [Nouveau] [PATCH] drm: nouveau: move bounds checking to the front in nouveau_svm_fault_buffer_dtor()
Date: Wed, 14 Sep 2022 15:10:50 +0800 [thread overview]
Message-ID: <20220914071050.21823-1-hbh25y@gmail.com> (raw)
It is better to check i before use it in array to avoid potential out of
bound access.
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
drivers/gpu/drm/nouveau/nouveau_svm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 31a5b81ee9fc..5c49a8eaf593 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -957,7 +957,7 @@ nouveau_svm_fault_buffer_dtor(struct nouveau_svm *svm, int id)
int i;
if (buffer->fault) {
- for (i = 0; buffer->fault[i] && i < buffer->entries; i++)
+ for (i = 0; i < buffer->entries && buffer->fault[i]; i++)
kfree(buffer->fault[i]);
kvfree(buffer->fault);
}
--
2.34.1
reply other threads:[~2022-09-20 21:24 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220914071050.21823-1-hbh25y@gmail.com \
--to=hbh25y@gmail.com \
--cc=airlied@linux.ie \
--cc=bskeggs@redhat.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).