drivers/accessibility/speakup/serialio.c:54 spk_serial_init() warn: always true condition '(index >= (0 / 20 + (0))) => (s32min-s32max >= 0)'

From: kernel test robot
Date: Fri Jan 08 2021 - 12:35:18 EST


Hi Samuel,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f5e6c330254ae691f6d7befe61c786eb5056007e
commit: 2067fd92d75b6d9085a43caf050bca5d88c491b8 staging/speakup: Move out of staging
date: 5 months ago
config: openrisc-randconfig-m031-20210108 (attached as .config)
compiler: or1k-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

smatch warnings:
drivers/accessibility/speakup/serialio.c:54 spk_serial_init() warn: always true condition '(index >= (0 / 20 + (0))) => (s32min-s32max >= 0)'

vim +54 drivers/accessibility/speakup/serialio.c

1e441594e509c35 drivers/staging/speakup/serialio.c Okash Khawaja 2017-03-14 45
3ee0017e03cd790 drivers/staging/speakup/serialio.c Jiri Slaby 2012-03-05 46 const struct old_serial_port *spk_serial_init(int index)
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 47 {
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 48 int baud = 9600, quot = 0;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 49 unsigned int cval = 0;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 50 int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 51 const struct old_serial_port *ser;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 52 int err;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 53
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 @54 if (index >= ARRAY_SIZE(rs_table)) {
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 55 pr_info("no port info for ttyS%d\n", index);
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 56 return NULL;
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 57 }
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 58 ser = rs_table + index;
327b882d3bcc1fb drivers/staging/speakup/serialio.c Samuel Thibault 2016-01-15 59
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 60 /* Divisor, bytesize and parity */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 61 quot = ser->baud_base / baud;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 62 cval = cflag & (CSIZE | CSTOPB);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 63 #if defined(__powerpc__) || defined(__alpha__)
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 64 cval >>= 8;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 65 #else /* !__powerpc__ && !__alpha__ */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 66 cval >>= 4;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 67 #endif /* !__powerpc__ && !__alpha__ */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 68 if (cflag & PARENB)
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 69 cval |= UART_LCR_PARITY;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 70 if (!(cflag & PARODD))
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 71 cval |= UART_LCR_EPAR;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 72 if (synth_request_region(ser->port, 8)) {
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 73 /* try to take it back. */
3a046c19158e897 drivers/staging/speakup/serialio.c Keerthimai Janarthanan 2014-03-18 74 pr_info("Ports not available, trying to steal them\n");
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 75 __release_region(&ioport_resource, ser->port, 8);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 76 err = synth_request_region(ser->port, 8);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 77 if (err) {
3ee0017e03cd790 drivers/staging/speakup/serialio.c Jiri Slaby 2012-03-05 78 pr_warn("Unable to allocate port at %x, errno %i",
baf9ac9ff8864ce drivers/staging/speakup/serialio.c William Hubbs 2010-10-15 79 ser->port, err);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 80 return NULL;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 81 }
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 82 }
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 83
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 84 /* Disable UART interrupts, set DTR and RTS high
13d825edd4441dd drivers/staging/speakup/serialio.c Aleksei Fedotov 2015-08-14 85 * and set speed.
13d825edd4441dd drivers/staging/speakup/serialio.c Aleksei Fedotov 2015-08-14 86 */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 87 outb(cval | UART_LCR_DLAB, ser->port + UART_LCR); /* set DLAB */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 88 outb(quot & 0xff, ser->port + UART_DLL); /* LS of divisor */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 89 outb(quot >> 8, ser->port + UART_DLM); /* MS of divisor */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 90 outb(cval, ser->port + UART_LCR); /* reset DLAB */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 91
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 92 /* Turn off Interrupts */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 93 outb(0, ser->port + UART_IER);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 94 outb(UART_MCR_DTR | UART_MCR_RTS, ser->port + UART_MCR);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 95
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 96 /* If we read 0xff from the LSR, there is no UART here. */
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 97 if (inb(ser->port + UART_LSR) == 0xff) {
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 98 synth_release_region(ser->port, 8);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 99 serstate = NULL;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 100 return NULL;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 101 }
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 102
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 103 mdelay(1);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 104 speakup_info.port_tts = ser->port;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 105 serstate = ser;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 106
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 107 start_serial_interrupt(ser->irq);
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 108
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 109 return ser;
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 110 }
c6e3fd22cd53836 drivers/staging/speakup/serialio.c William Hubbs 2010-10-07 111

:::::: The code at line 54 was first introduced by commit
:::::: 327b882d3bcc1fba82dbd39b5cf5a838c81218e2 Staging: speakup: Fix getting port information

:::::: TO: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip