From: kbuild test robot <lkp@intel.com>
To: Nicolas Pitre <nico@fluxnic.net>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: drivers/tty/vt/vt.c:1210:22: warning: comparison is always false due to limited range of data type
Date: Tue, 19 May 2020 10:33:49 +0800 [thread overview]
Message-ID: <202005191047.9S9G4sqQ%lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 6266 bytes --]
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 642b151f45dd54809ea00ecd3976a56c1ec9b53d
commit: 2717769e204e83e65b8819c5e2ef3e5b6639b270 vt: don't hardcode the mem allocation upper bound
date: 4 weeks ago
config: ia64-defconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 2717769e204e83e65b8819c5e2ef3e5b6639b270
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@intel.com>
All warnings (new ones prefixed by >>, old ones prefixed by <<):
drivers/tty/vt/vt.c: In function 'vc_do_resize':
>> drivers/tty/vt/vt.c:1210:22: warning: comparison is always false due to limited range of data type [-Wtype-limits]
1210 | if (new_screen_size > KMALLOC_MAX_SIZE)
| ^
vim +1210 drivers/tty/vt/vt.c
1163
1164 /**
1165 * vc_do_resize - resizing method for the tty
1166 * @tty: tty being resized
1167 * @real_tty: real tty (different to tty if a pty/tty pair)
1168 * @vc: virtual console private data
1169 * @cols: columns
1170 * @lines: lines
1171 *
1172 * Resize a virtual console, clipping according to the actual constraints.
1173 * If the caller passes a tty structure then update the termios winsize
1174 * information and perform any necessary signal handling.
1175 *
1176 * Caller must hold the console semaphore. Takes the termios rwsem and
1177 * ctrl_lock of the tty IFF a tty is passed.
1178 */
1179
1180 static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1181 unsigned int cols, unsigned int lines)
1182 {
1183 unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0;
1184 unsigned long end;
1185 unsigned int old_rows, old_row_size, first_copied_row;
1186 unsigned int new_cols, new_rows, new_row_size, new_screen_size;
1187 unsigned int user;
1188 unsigned short *newscreen;
1189 struct uni_screen *new_uniscr = NULL;
1190
1191 WARN_CONSOLE_UNLOCKED();
1192
1193 if (!vc)
1194 return -ENXIO;
1195
1196 user = vc->vc_resize_user;
1197 vc->vc_resize_user = 0;
1198
1199 if (cols > VC_RESIZE_MAXCOL || lines > VC_RESIZE_MAXROW)
1200 return -EINVAL;
1201
1202 new_cols = (cols ? cols : vc->vc_cols);
1203 new_rows = (lines ? lines : vc->vc_rows);
1204 new_row_size = new_cols << 1;
1205 new_screen_size = new_row_size * new_rows;
1206
1207 if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
1208 return 0;
1209
> 1210 if (new_screen_size > KMALLOC_MAX_SIZE)
1211 return -EINVAL;
1212 newscreen = kzalloc(new_screen_size, GFP_USER);
1213 if (!newscreen)
1214 return -ENOMEM;
1215
1216 if (get_vc_uniscr(vc)) {
1217 new_uniscr = vc_uniscr_alloc(new_cols, new_rows);
1218 if (!new_uniscr) {
1219 kfree(newscreen);
1220 return -ENOMEM;
1221 }
1222 }
1223
1224 if (vc_is_sel(vc))
1225 clear_selection();
1226
1227 old_rows = vc->vc_rows;
1228 old_row_size = vc->vc_size_row;
1229
1230 err = resize_screen(vc, new_cols, new_rows, user);
1231 if (err) {
1232 kfree(newscreen);
1233 kfree(new_uniscr);
1234 return err;
1235 }
1236
1237 vc->vc_rows = new_rows;
1238 vc->vc_cols = new_cols;
1239 vc->vc_size_row = new_row_size;
1240 vc->vc_screenbuf_size = new_screen_size;
1241
1242 rlth = min(old_row_size, new_row_size);
1243 rrem = new_row_size - rlth;
1244 old_origin = vc->vc_origin;
1245 new_origin = (long) newscreen;
1246 new_scr_end = new_origin + new_screen_size;
1247
1248 if (vc->vc_y > new_rows) {
1249 if (old_rows - vc->vc_y < new_rows) {
1250 /*
1251 * Cursor near the bottom, copy contents from the
1252 * bottom of buffer
1253 */
1254 first_copied_row = (old_rows - new_rows);
1255 } else {
1256 /*
1257 * Cursor is in no man's land, copy 1/2 screenful
1258 * from the top and bottom of cursor position
1259 */
1260 first_copied_row = (vc->vc_y - new_rows/2);
1261 }
1262 old_origin += first_copied_row * old_row_size;
1263 } else
1264 first_copied_row = 0;
1265 end = old_origin + old_row_size * min(old_rows, new_rows);
1266
1267 vc_uniscr_copy_area(new_uniscr, new_cols, new_rows,
1268 get_vc_uniscr(vc), rlth/2, first_copied_row,
1269 min(old_rows, new_rows));
1270 vc_uniscr_set(vc, new_uniscr);
1271
1272 update_attr(vc);
1273
1274 while (old_origin < end) {
1275 scr_memcpyw((unsigned short *) new_origin,
1276 (unsigned short *) old_origin, rlth);
1277 if (rrem)
1278 scr_memsetw((void *)(new_origin + rlth),
1279 vc->vc_video_erase_char, rrem);
1280 old_origin += old_row_size;
1281 new_origin += new_row_size;
1282 }
1283 if (new_scr_end > new_origin)
1284 scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
1285 new_scr_end - new_origin);
1286 kfree(vc->vc_screenbuf);
1287 vc->vc_screenbuf = newscreen;
1288 vc->vc_screenbuf_size = new_screen_size;
1289 set_origin(vc);
1290
1291 /* do part of a reset_terminal() */
1292 vc->vc_top = 0;
1293 vc->vc_bottom = vc->vc_rows;
1294 gotoxy(vc, vc->vc_x, vc->vc_y);
1295 save_cur(vc);
1296
1297 if (tty) {
1298 /* Rewrite the requested winsize data with the actual
1299 resulting sizes */
1300 struct winsize ws;
1301 memset(&ws, 0, sizeof(ws));
1302 ws.ws_row = vc->vc_rows;
1303 ws.ws_col = vc->vc_cols;
1304 ws.ws_ypixel = vc->vc_scan_lines;
1305 tty_do_resize(tty, &ws);
1306 }
1307
1308 if (con_is_visible(vc))
1309 update_screen(vc);
1310 vt_event_post(VT_EVENT_RESIZE, vc->vc_num, vc->vc_num);
1311 notify_update(vc);
1312 return err;
1313 }
1314
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 20091 bytes --]
next reply other threads:[~2020-05-19 2:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 2:33 kbuild test robot [this message]
2020-06-15 6:24 kernel test robot
2020-06-17 16:15 ` Nicolas Pitre
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=202005191047.9S9G4sqQ%lkp@intel.com \
--to=lkp@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nico@fluxnic.net \
/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
all inboxes | Powered by JetHome®