<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p></p>
<div>
<div></div>
<div>add return-value check of ftell to improve robustness(and avoid abnormal behavior)</div>
<div><br>
</div>
<div>Signed-off-by: SPeak <speakshen@163.com></div>
<div><span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">Signed-off-by: shenyanfeng <shenyanfeng@xiaomi.com></span><br>
</div>
<div>---</div>
<div> drivers/gpu/drm/radeon/mkregtable.c | 5 +++--</div>
<div> 1 file changed, 3 insertions(+), 2 deletions(-)</div>
<div><br>
</div>
<div>diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c</div>
<div>index 52a7246fe..c31c58e5f 100644</div>
<div>--- a/drivers/gpu/drm/radeon/mkregtable.c</div>
<div>+++ b/drivers/gpu/drm/radeon/mkregtable.c</div>
<div>@@ -193,6 +193,7 @@ static int parser_auth(struct table *t, const char *filename)</div>
<div> <span style="white-space:pre"> </span>regmatch_t match[4];</div>
<div> <span style="white-space:pre"> </span>char buf[1024];</div>
<div> <span style="white-space:pre"> </span>size_t end;</div>
<div>+<span style="white-space:pre"> </span>long pos;</div>
<div> <span style="white-space:pre"> </span>int len;</div>
<div> <span style="white-space:pre"> </span>int done = 0;</div>
<div> <span style="white-space:pre"> </span>int r;</div>
<div>@@ -228,12 +229,12 @@ static int parser_auth(struct table *t, const char *filename)</div>
<div> <span style="white-space:pre"> </span>last_reg = strtol(last_reg_s, NULL, 16);</div>
<div> </div>
<div> <span style="white-space:pre"> </span>do {</div>
<div>-<span style="white-space:pre"> </span>if (fgets(buf, 1024, file) == NULL) {</div>
<div>+<span style="white-space:pre"> </span>if ((fgets(buf, 1024, file) == NULL) || (pos = ftell(file)) < 0) {</div>
<div> <span style="white-space:pre"> </span>fclose(file);</div>
<div> <span style="white-space:pre"> </span>return -1;</div>
<div> <span style="white-space:pre"> </span>}</div>
<div> <span style="white-space:pre"> </span>len = strlen(buf);</div>
<div>-<span style="white-space:pre"> </span>if (ftell(file) == end)</div>
<div>+<span style="white-space:pre"> </span>if (pos == end)</div>
<div> <span style="white-space:pre"> </span>done = 1;</div>
<div> <span style="white-space:pre"> </span>if (len) {</div>
<div> <span style="white-space:pre"> </span>r = regexec(&mask_rex, buf, 4, match, 0);</div>
<div>-- </div>
<div>2.37.2</div>
</div>
<p></p>
</div>
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! 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!******/#
</body>
</html>