From: 沈言峰 <shenyanfeng@xiaomi.com>
To: "airlied@gmail.com" <airlied@gmail.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"Xinhui.Pan@amd.com" <Xinhui.Pan@amd.com>
Cc: "dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Subject: [PATCH] driver: gpu: add failure check for ftell
Date: Sat, 29 Oct 2022 08:30:00 +0000 [thread overview]
Message-ID: <dcbdea48b4554f1989b2b7c6ebc9e32d@xiaomi.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1851 bytes --]
add return-value check of ftell to improve robustness(and avoid abnormal behavior)
Signed-off-by: SPeak <speakshen@163.com>
Signed-off-by: shenyanfeng <shenyanfeng@xiaomi.com>
---
drivers/gpu/drm/radeon/mkregtable.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
index 52a7246fe..c31c58e5f 100644
--- a/drivers/gpu/drm/radeon/mkregtable.c
+++ b/drivers/gpu/drm/radeon/mkregtable.c
@@ -193,6 +193,7 @@ static int parser_auth(struct table *t, const char *filename)
regmatch_t match[4];
char buf[1024];
size_t end;
+ long pos;
int len;
int done = 0;
int r;
@@ -228,12 +229,12 @@ static int parser_auth(struct table *t, const char *filename)
last_reg = strtol(last_reg_s, NULL, 16);
do {
- if (fgets(buf, 1024, file) == NULL) {
+ if ((fgets(buf, 1024, file) == NULL) || (pos = ftell(file)) < 0) {
fclose(file);
return -1;
}
len = strlen(buf);
- if (ftell(file) == end)
+ if (pos == end)
done = 1;
if (len) {
r = regexec(&mask_rex, buf, 4, match, 0);
--
2.37.2
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#
[-- Attachment #2: Type: text/html, Size: 3825 bytes --]
reply other threads:[~2022-10-31 8:14 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=dcbdea48b4554f1989b2b7c6ebc9e32d@xiaomi.com \
--to=shenyanfeng@xiaomi.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.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