Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [jirislaby:devel 48/49] drivers/usb/serial/console.c:146:19: error: incompatible pointer types passing 'struct xarray *' to parameter of type 'struct list_head *'
@ 2025-01-30 16:52 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2025-01-30 16:52 UTC (permalink / raw)
  To: Jiri Slaby (SUSE); +Cc: llvm, oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/jirislaby/linux.git devel
head:   a2ea6ca94c68a7ab616969102e07614d1be0a5a8
commit: 4e755fc98e41dca2debd4bb09e1d10d59d9168da [48/49] tty: use xarray for tty's file list
config: i386-buildonly-randconfig-001-20250130 (https://download.01.org/0day-ci/archive/20250131/202501310050.yF1EHHMy-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250131/202501310050.yF1EHHMy-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501310050.yF1EHHMy-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/usb/serial/console.c:146:19: error: incompatible pointer types passing 'struct xarray *' to parameter of type 'struct list_head *' [-Werror,-Wincompatible-pointer-types]
     146 |                         INIT_LIST_HEAD(&tty->tty_files);
         |                                        ^~~~~~~~~~~~~~~
   include/linux/list.h:35:53: note: passing argument to parameter 'list' here
      35 | static inline void INIT_LIST_HEAD(struct list_head *list)
         |                                                     ^
   1 error generated.


vim +146 drivers/usb/serial/console.c

^1da177e4c3f415 Linus Torvalds     2005-04-16   49  
^1da177e4c3f415 Linus Torvalds     2005-04-16   50  /*
^1da177e4c3f415 Linus Torvalds     2005-04-16   51   * The parsing of the command line works exactly like the
^1da177e4c3f415 Linus Torvalds     2005-04-16   52   * serial.c code, except that the specifier is "ttyUSB" instead
^1da177e4c3f415 Linus Torvalds     2005-04-16   53   * of "ttyS".
^1da177e4c3f415 Linus Torvalds     2005-04-16   54   */
69a4bf7c9525e5c Paul Fulghum       2006-04-12   55  static int usb_console_setup(struct console *co, char *options)
^1da177e4c3f415 Linus Torvalds     2005-04-16   56  {
^1da177e4c3f415 Linus Torvalds     2005-04-16   57  	struct usbcons_info *info = &usbcons_info;
^1da177e4c3f415 Linus Torvalds     2005-04-16   58  	int baud = 9600;
^1da177e4c3f415 Linus Torvalds     2005-04-16   59  	int bits = 8;
^1da177e4c3f415 Linus Torvalds     2005-04-16   60  	int parity = 'n';
^1da177e4c3f415 Linus Torvalds     2005-04-16   61  	int doflow = 0;
^1da177e4c3f415 Linus Torvalds     2005-04-16   62  	int cflag = CREAD | HUPCL | CLOCAL;
^1da177e4c3f415 Linus Torvalds     2005-04-16   63  	char *s;
^1da177e4c3f415 Linus Torvalds     2005-04-16   64  	struct usb_serial *serial;
^1da177e4c3f415 Linus Torvalds     2005-04-16   65  	struct usb_serial_port *port;
7bd032dc2793afc Alan Stern         2009-09-04   66  	int retval;
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13   67  	struct tty_struct *tty = NULL;
92d2c5e4badc622 Jason Wessel       2010-03-16   68  	struct ktermios dummy;
^1da177e4c3f415 Linus Torvalds     2005-04-16   69  
^1da177e4c3f415 Linus Torvalds     2005-04-16   70  	if (options) {
^1da177e4c3f415 Linus Torvalds     2005-04-16   71  		baud = simple_strtoul(options, NULL, 10);
^1da177e4c3f415 Linus Torvalds     2005-04-16   72  		s = options;
^1da177e4c3f415 Linus Torvalds     2005-04-16   73  		while (*s >= '0' && *s <= '9')
^1da177e4c3f415 Linus Torvalds     2005-04-16   74  			s++;
^1da177e4c3f415 Linus Torvalds     2005-04-16   75  		if (*s)
^1da177e4c3f415 Linus Torvalds     2005-04-16   76  			parity = *s++;
^1da177e4c3f415 Linus Torvalds     2005-04-16   77  		if (*s)
^1da177e4c3f415 Linus Torvalds     2005-04-16   78  			bits   = *s++ - '0';
^1da177e4c3f415 Linus Torvalds     2005-04-16   79  		if (*s)
^1da177e4c3f415 Linus Torvalds     2005-04-16   80  			doflow = (*s++ == 'r');
^1da177e4c3f415 Linus Torvalds     2005-04-16   81  	}
^1da177e4c3f415 Linus Torvalds     2005-04-16   82  
c17ee886976b64d Alan Cox           2008-07-22   83  	/* Sane default */
c17ee886976b64d Alan Cox           2008-07-22   84  	if (baud == 0)
^1da177e4c3f415 Linus Torvalds     2005-04-16   85  		baud = 9600;
c17ee886976b64d Alan Cox           2008-07-22   86  
^1da177e4c3f415 Linus Torvalds     2005-04-16   87  	switch (bits) {
^1da177e4c3f415 Linus Torvalds     2005-04-16   88  	case 7:
^1da177e4c3f415 Linus Torvalds     2005-04-16   89  		cflag |= CS7;
^1da177e4c3f415 Linus Torvalds     2005-04-16   90  		break;
^1da177e4c3f415 Linus Torvalds     2005-04-16   91  	default:
^1da177e4c3f415 Linus Torvalds     2005-04-16   92  	case 8:
^1da177e4c3f415 Linus Torvalds     2005-04-16   93  		cflag |= CS8;
^1da177e4c3f415 Linus Torvalds     2005-04-16   94  		break;
^1da177e4c3f415 Linus Torvalds     2005-04-16   95  	}
^1da177e4c3f415 Linus Torvalds     2005-04-16   96  	switch (parity) {
^1da177e4c3f415 Linus Torvalds     2005-04-16   97  	case 'o': case 'O':
^1da177e4c3f415 Linus Torvalds     2005-04-16   98  		cflag |= PARODD;
^1da177e4c3f415 Linus Torvalds     2005-04-16   99  		break;
^1da177e4c3f415 Linus Torvalds     2005-04-16  100  	case 'e': case 'E':
^1da177e4c3f415 Linus Torvalds     2005-04-16  101  		cflag |= PARENB;
^1da177e4c3f415 Linus Torvalds     2005-04-16  102  		break;
^1da177e4c3f415 Linus Torvalds     2005-04-16  103  	}
^1da177e4c3f415 Linus Torvalds     2005-04-16  104  
cabe0785ff14e94 Johan Hovold       2020-07-01  105  	if (doflow)
cabe0785ff14e94 Johan Hovold       2020-07-01  106  		cflag |= CRTSCTS;
cabe0785ff14e94 Johan Hovold       2020-07-01  107  
27680d232b04d43 Aristeu Rozanski   2007-11-12  108  	/*
27680d232b04d43 Aristeu Rozanski   2007-11-12  109  	 * no need to check the index here: if the index is wrong, console
27680d232b04d43 Aristeu Rozanski   2007-11-12  110  	 * code won't call us
27680d232b04d43 Aristeu Rozanski   2007-11-12  111  	 */
e5b1e2062e0535e Greg Kroah-Hartman 2013-06-07  112  	port = usb_serial_port_get_by_minor(co->index);
e5b1e2062e0535e Greg Kroah-Hartman 2013-06-07  113  	if (port == NULL) {
^1da177e4c3f415 Linus Torvalds     2005-04-16  114  		/* no device is connected yet, sorry :( */
92931d243b5cafa Greg Kroah-Hartman 2012-09-13  115  		pr_err("No USB device connected to ttyUSB%i\n", co->index);
^1da177e4c3f415 Linus Torvalds     2005-04-16  116  		return -ENODEV;
^1da177e4c3f415 Linus Torvalds     2005-04-16  117  	}
e5b1e2062e0535e Greg Kroah-Hartman 2013-06-07  118  	serial = port->serial;
^1da177e4c3f415 Linus Torvalds     2005-04-16  119  
7bd032dc2793afc Alan Stern         2009-09-04  120  	retval = usb_autopm_get_interface(serial->interface);
7bd032dc2793afc Alan Stern         2009-09-04  121  	if (retval)
7bd032dc2793afc Alan Stern         2009-09-04  122  		goto error_get_interface;
7bd032dc2793afc Alan Stern         2009-09-04  123  
4a90f09b20f4622 Alan Cox           2008-10-13  124  	tty_port_tty_set(&port->port, NULL);
^1da177e4c3f415 Linus Torvalds     2005-04-16  125  
^1da177e4c3f415 Linus Torvalds     2005-04-16  126  	info->port = port;
^1da177e4c3f415 Linus Torvalds     2005-04-16  127  
95da310e66ee809 Alan Cox           2008-07-22  128  	++port->port.count;
d41861ca19c9e96 Peter Hurley       2016-04-09  129  	if (!tty_port_initialized(&port->port)) {
^1da177e4c3f415 Linus Torvalds     2005-04-16  130  		if (serial->type->set_termios) {
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  131  			/*
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  132  			 * allocate a fake tty so the driver can initialize
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  133  			 * the termios structure, then later call set_termios to
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  134  			 * configure according to command line arguments
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  135  			 */
7ac9da10af7ffd9 Burman Yan         2006-11-22  136  			tty = kzalloc(sizeof(*tty), GFP_KERNEL);
^1da177e4c3f415 Linus Torvalds     2005-04-16  137  			if (!tty) {
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  138  				retval = -ENOMEM;
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  139  				goto reset_open_count;
^1da177e4c3f415 Linus Torvalds     2005-04-16  140  			}
e5404586a499f7d Kevin Hao          2008-12-01  141  			kref_init(&tty->kref);
92d2c5e4badc622 Jason Wessel       2010-03-16  142  			tty->driver = usb_serial_tty_driver;
92d2c5e4badc622 Jason Wessel       2010-03-16  143  			tty->index = co->index;
d269d4434c72ed0 Johan Hovold       2015-01-05  144  			init_ldsem(&tty->ldisc_sem);
14816b16fa0adac Johan Hovold       2017-02-08  145  			spin_lock_init(&tty->files_lock);
32a4bf2e81ec378 Johan Hovold       2015-01-05 @146  			INIT_LIST_HEAD(&tty->tty_files);
32a4bf2e81ec378 Johan Hovold       2015-01-05  147  			kref_get(&tty->driver->kref);
5ee0089b1f7057d Johan Hovold       2015-02-16  148  			__module_get(tty->driver->owner);
32a4bf2e81ec378 Johan Hovold       2015-01-05  149  			tty->ops = &usb_console_fake_tty_ops;
a3123fd0a4a5f9d Peter Hurley       2016-01-09  150  			tty_init_termios(tty);
32a4bf2e81ec378 Johan Hovold       2015-01-05  151  			tty_port_tty_set(&port->port, tty);
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  152  		}
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  153  
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  154  		/* only call the device specific open if this
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  155  		 * is the first time the port is opened */
a509a7e478e4766 Alan Cox           2009-09-19  156  		retval = serial->type->open(NULL, port);
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  157  		if (retval) {
085fb962623b727 Greg Kroah-Hartman 2012-04-20  158  			dev_err(&port->dev, "could not open USB console port\n");
92d2c5e4badc622 Jason Wessel       2010-03-16  159  			goto fail;
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  160  		}
^1da177e4c3f415 Linus Torvalds     2005-04-16  161  
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  162  		if (serial->type->set_termios) {
2d8a1001ee0e961 Stephen Rothwell   2012-07-20  163  			tty->termios.c_cflag = cflag;
2d8a1001ee0e961 Stephen Rothwell   2012-07-20  164  			tty_termios_encode_baud_rate(&tty->termios, baud, baud);
92d2c5e4badc622 Jason Wessel       2010-03-16  165  			memset(&dummy, 0, sizeof(struct ktermios));
06dd881f59b3c07 Jason Wessel       2008-09-08  166  			serial->type->set_termios(tty, port, &dummy);
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  167  
4a90f09b20f4622 Alan Cox           2008-10-13  168  			tty_port_tty_set(&port->port, NULL);
f51ccf46217c287 Johan Hovold       2018-12-04  169  			tty_save_termios(tty);
32a4bf2e81ec378 Johan Hovold       2015-01-05  170  			tty_kref_put(tty);
^1da177e4c3f415 Linus Torvalds     2005-04-16  171  		}
515be7baeddb04d Ilpo Järvinen      2023-01-17  172  		tty_port_set_initialized(&port->port, true);
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  173  	}
6e4061210150d1d Jason Wessel       2009-06-22  174  	/* Now that any required fake tty operations are completed restore
6e4061210150d1d Jason Wessel       2009-06-22  175  	 * the tty port count */
6e4061210150d1d Jason Wessel       2009-06-22  176  	--port->port.count;
6e4061210150d1d Jason Wessel       2009-06-22  177  	/* The console is special in terms of closing the device so
6e4061210150d1d Jason Wessel       2009-06-22  178  	 * indicate this port is now acting as a system console. */
336cee42dd52824 Jason Wessel       2010-03-08  179  	port->port.console = 1;
^1da177e4c3f415 Linus Torvalds     2005-04-16  180  
7bd032dc2793afc Alan Stern         2009-09-04  181  	mutex_unlock(&serial->disc_mutex);
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  182  	return retval;
7bd032dc2793afc Alan Stern         2009-09-04  183  
92d2c5e4badc622 Jason Wessel       2010-03-16  184   fail:
4a90f09b20f4622 Alan Cox           2008-10-13  185  	tty_port_tty_set(&port->port, NULL);
32a4bf2e81ec378 Johan Hovold       2015-01-05  186  	tty_kref_put(tty);
c87d6a4f67657f4 Aristeu Rozanski   2007-11-13  187   reset_open_count:
95da310e66ee809 Alan Cox           2008-07-22  188  	port->port.count = 0;
299d7572e46f985 Johan Hovold       2017-10-04  189  	info->port = NULL;
7bd032dc2793afc Alan Stern         2009-09-04  190  	usb_autopm_put_interface(serial->interface);
7bd032dc2793afc Alan Stern         2009-09-04  191   error_get_interface:
7bd032dc2793afc Alan Stern         2009-09-04  192  	mutex_unlock(&serial->disc_mutex);
61dfa797c731754 Liang He           2022-09-19  193  	usb_serial_put(serial);
7bd032dc2793afc Alan Stern         2009-09-04  194  	return retval;
^1da177e4c3f415 Linus Torvalds     2005-04-16  195  }
^1da177e4c3f415 Linus Torvalds     2005-04-16  196  

:::::: The code at line 146 was first introduced by commit
:::::: 32a4bf2e81ec378e5925d4e069e0677a6c86a6ad USB: console: fix potential use after free

:::::: TO: Johan Hovold <johan@kernel.org>
:::::: CC: Johan Hovold <johan@kernel.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-30 16:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-30 16:52 [jirislaby:devel 48/49] drivers/usb/serial/console.c:146:19: error: incompatible pointer types passing 'struct xarray *' to parameter of type 'struct list_head *' kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox