All of lore.kernel.org
 help / color / mirror / Atom feed
* [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list
@ 2023-10-18  9:57 Dan Carpenter
  2023-10-18 12:39 ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2023-10-18  9:57 UTC (permalink / raw)
  To: oe-kbuild, Andy Shevchenko; +Cc: lkp, oe-kbuild-all, Greg Kroah-Hartman

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-testing
head:   5ab2ef71d3e0a4b8e5839b1850ccdd236695e2e0
commit: 6c9334e9230e552c795eebd34e6b208c6df693fe [21/23] parport: Use kasprintf() instead of fixed buffer formatting
config: i386-randconfig-141-20231017 (https://download.01.org/0day-ci/archive/20231018/202310180809.hepZB9k6-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231018/202310180809.hepZB9k6-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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202310180809.hepZB9k6-lkp@intel.com/

New smatch warnings:
drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list

Old smatch warnings:
drivers/parport/share.c:826 parport_register_dev_model() warn: possible memory leak of 'par_dev'

vim +486 drivers/parport/share.c

^1da177e4c3f41 Linus Torvalds      2005-04-16  434  struct parport *parport_register_port(unsigned long base, int irq, int dma,
^1da177e4c3f41 Linus Torvalds      2005-04-16  435  				      struct parport_operations *ops)
^1da177e4c3f41 Linus Torvalds      2005-04-16  436  {
^1da177e4c3f41 Linus Torvalds      2005-04-16  437  	struct list_head *l;
^1da177e4c3f41 Linus Torvalds      2005-04-16  438  	struct parport *tmp;
^1da177e4c3f41 Linus Torvalds      2005-04-16  439  	int num;
^1da177e4c3f41 Linus Torvalds      2005-04-16  440  	int device;
6fa45a22689722 Sudip Mukherjee     2015-05-20  441  	int ret;
^1da177e4c3f41 Linus Torvalds      2005-04-16  442  
c32df4e182e5bf Alexandru Gheorghiu 2013-07-03  443  	tmp = kzalloc(sizeof(struct parport), GFP_KERNEL);
47ec57ec0e5283 Sudip Mukherjee     2015-10-28  444  	if (!tmp)
^1da177e4c3f41 Linus Torvalds      2005-04-16  445  		return NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16  446  
^1da177e4c3f41 Linus Torvalds      2005-04-16  447  	/* Init our structure */
^1da177e4c3f41 Linus Torvalds      2005-04-16  448  	tmp->base = base;
^1da177e4c3f41 Linus Torvalds      2005-04-16  449  	tmp->irq = irq;
^1da177e4c3f41 Linus Torvalds      2005-04-16  450  	tmp->dma = dma;
^1da177e4c3f41 Linus Torvalds      2005-04-16  451  	tmp->muxport = tmp->daisy = tmp->muxsel = -1;
^1da177e4c3f41 Linus Torvalds      2005-04-16  452  	tmp->modes = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  453  	INIT_LIST_HEAD(&tmp->list);
^1da177e4c3f41 Linus Torvalds      2005-04-16  454  	tmp->devices = tmp->cad = NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16  455  	tmp->flags = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  456  	tmp->ops = ops;
^1da177e4c3f41 Linus Torvalds      2005-04-16  457  	tmp->physport = tmp;
^1da177e4c3f41 Linus Torvalds      2005-04-16  458  	memset(tmp->probe_info, 0, 5 * sizeof(struct parport_device_info));
^1da177e4c3f41 Linus Torvalds      2005-04-16  459  	rwlock_init(&tmp->cad_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  460  	spin_lock_init(&tmp->waitlist_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  461  	spin_lock_init(&tmp->pardevice_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  462  	tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
^1da177e4c3f41 Linus Torvalds      2005-04-16  463  	tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
a529f1505b6fac Thomas Gleixner     2010-09-07  464  	sema_init(&tmp->ieee1284.irq, 0);
^1da177e4c3f41 Linus Torvalds      2005-04-16  465  	tmp->spintime = parport_default_spintime;
^1da177e4c3f41 Linus Torvalds      2005-04-16  466  	atomic_set(&tmp->ref_count, 1);
^1da177e4c3f41 Linus Torvalds      2005-04-16  467  	INIT_LIST_HEAD(&tmp->full_list);
^1da177e4c3f41 Linus Torvalds      2005-04-16  468  
^1da177e4c3f41 Linus Torvalds      2005-04-16  469  	/* Search for the lowest free parport number. */
^1da177e4c3f41 Linus Torvalds      2005-04-16  470  
^1da177e4c3f41 Linus Torvalds      2005-04-16  471  	spin_lock(&full_list_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  472  	for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) {
^1da177e4c3f41 Linus Torvalds      2005-04-16  473  		struct parport *p = list_entry(l, struct parport, full_list);
^1da177e4c3f41 Linus Torvalds      2005-04-16  474  		if (p->number != num)
^1da177e4c3f41 Linus Torvalds      2005-04-16  475  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  476  	}
^1da177e4c3f41 Linus Torvalds      2005-04-16  477  	tmp->portnum = tmp->number = num;
^1da177e4c3f41 Linus Torvalds      2005-04-16  478  	list_add_tail(&tmp->full_list, l);

tmp gets added to the all_ports list here

^1da177e4c3f41 Linus Torvalds      2005-04-16  479  	spin_unlock(&full_list_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  480  
^1da177e4c3f41 Linus Torvalds      2005-04-16  481  	/*
^1da177e4c3f41 Linus Torvalds      2005-04-16  482  	 * Now that the portnum is known finish doing the Init.
^1da177e4c3f41 Linus Torvalds      2005-04-16  483  	 */
6c9334e9230e55 Andy Shevchenko     2023-10-16  484  	tmp->name = kasprintf(GFP_KERNEL, "parport%d", tmp->portnum);
6c9334e9230e55 Andy Shevchenko     2023-10-16  485  	if (!tmp->name) {
6c9334e9230e55 Andy Shevchenko     2023-10-16 @486  		kfree(tmp);

This kfree will lead to a use after free.  Also tmp is such a terribly
confusing name for something that isn't temporary at all.

6c9334e9230e55 Andy Shevchenko     2023-10-16  487  		return NULL;
6c9334e9230e55 Andy Shevchenko     2023-10-16  488  	}
6c9334e9230e55 Andy Shevchenko     2023-10-16  489  	dev_set_name(&tmp->bus_dev, tmp->name);
6fa45a22689722 Sudip Mukherjee     2015-05-20  490  	tmp->bus_dev.bus = &parport_bus_type;
6fa45a22689722 Sudip Mukherjee     2015-05-20  491  	tmp->bus_dev.release = free_port;
6fa45a22689722 Sudip Mukherjee     2015-05-20  492  	tmp->bus_dev.type = &parport_device_type;
^1da177e4c3f41 Linus Torvalds      2005-04-16  493  
^1da177e4c3f41 Linus Torvalds      2005-04-16  494  	for (device = 0; device < 5; device++)
^1da177e4c3f41 Linus Torvalds      2005-04-16  495  		/* assume the worst */
^1da177e4c3f41 Linus Torvalds      2005-04-16  496  		tmp->probe_info[device].class = PARPORT_CLASS_LEGACY;
^1da177e4c3f41 Linus Torvalds      2005-04-16  497  
^1da177e4c3f41 Linus Torvalds      2005-04-16  498  	tmp->waithead = tmp->waittail = NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16  499  
6fa45a22689722 Sudip Mukherjee     2015-05-20  500  	ret = device_register(&tmp->bus_dev);
6fa45a22689722 Sudip Mukherjee     2015-05-20  501  	if (ret) {
6fa45a22689722 Sudip Mukherjee     2015-05-20  502  		put_device(&tmp->bus_dev);
6fa45a22689722 Sudip Mukherjee     2015-05-20  503  		return NULL;
6fa45a22689722 Sudip Mukherjee     2015-05-20  504  	}
6fa45a22689722 Sudip Mukherjee     2015-05-20  505  
^1da177e4c3f41 Linus Torvalds      2005-04-16  506  	return tmp;
^1da177e4c3f41 Linus Torvalds      2005-04-16  507  }

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list
  2023-10-18  9:57 [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list Dan Carpenter
@ 2023-10-18 12:39 ` Andy Shevchenko
  2023-10-18 12:41   ` Dan Carpenter
  2023-10-18 15:21   ` Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-10-18 12:39 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all, Greg Kroah-Hartman

On Wed, Oct 18, 2023 at 12:57:52PM +0300, Dan Carpenter wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-testing
> head:   5ab2ef71d3e0a4b8e5839b1850ccdd236695e2e0
> commit: 6c9334e9230e552c795eebd34e6b208c6df693fe [21/23] parport: Use kasprintf() instead of fixed buffer formatting
> config: i386-randconfig-141-20231017 (https://download.01.org/0day-ci/archive/20231018/202310180809.hepZB9k6-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce: (https://download.01.org/0day-ci/archive/20231018/202310180809.hepZB9k6-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>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202310180809.hepZB9k6-lkp@intel.com/
> 
> New smatch warnings:
> drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list


Indeed. The kasprintf() was squeezed into a wrong gap in the code.
Thanks, I'll send a fix soon.

> Old smatch warnings:
> drivers/parport/share.c:826 parport_register_dev_model() warn: possible memory leak of 'par_dev'

Means this was already be in the code?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list
  2023-10-18 12:39 ` Andy Shevchenko
@ 2023-10-18 12:41   ` Dan Carpenter
  2023-10-18 15:21   ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-10-18 12:41 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: oe-kbuild, lkp, oe-kbuild-all, Greg Kroah-Hartman

On Wed, Oct 18, 2023 at 03:39:24PM +0300, Andy Shevchenko wrote:
> > Old smatch warnings:
> > drivers/parport/share.c:826 parport_register_dev_model() warn: possible memory leak of 'par_dev'
> 
> Means this was already be in the code?

Yep.  It's not related to your patch but when people are working on a
file we like to push them to look at other stuff.  :P

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list
  2023-10-18 12:39 ` Andy Shevchenko
  2023-10-18 12:41   ` Dan Carpenter
@ 2023-10-18 15:21   ` Andy Shevchenko
  2023-10-18 16:57     ` Dan Carpenter
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-10-18 15:21 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all, Greg Kroah-Hartman

On Wed, Oct 18, 2023 at 03:39:24PM +0300, Andy Shevchenko wrote:
> On Wed, Oct 18, 2023 at 12:57:52PM +0300, Dan Carpenter wrote:

...

> > Old smatch warnings:
> > drivers/parport/share.c:826 parport_register_dev_model() warn: possible memory leak of 'par_dev'
> 
> Means this was already be in the code?

How is it not a false positive?

devmodel is false (so kfree _is_ called) until we get device_register() called.
After that it's done via put_device() in both possible error cases.

What did I miss?

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list
  2023-10-18 15:21   ` Andy Shevchenko
@ 2023-10-18 16:57     ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2023-10-18 16:57 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: oe-kbuild, lkp, oe-kbuild-all, Greg Kroah-Hartman

On Wed, Oct 18, 2023 at 06:21:10PM +0300, Andy Shevchenko wrote:
> On Wed, Oct 18, 2023 at 03:39:24PM +0300, Andy Shevchenko wrote:
> > On Wed, Oct 18, 2023 at 12:57:52PM +0300, Dan Carpenter wrote:
> 
> ...
> 
> > > Old smatch warnings:
> > > drivers/parport/share.c:826 parport_register_dev_model() warn: possible memory leak of 'par_dev'
> > 
> > Means this was already be in the code?
> 
> How is it not a false positive?
> 
> devmodel is false (so kfree _is_ called) until we get device_register() called.
> After that it's done via put_device() in both possible error cases.
> 
> What did I miss?

Oh, yeah.  You're right.  (I hadn't looked at the code before, I only
see what's in the email and hit the forward button).  This check is
normally super reliable but also useless because it missing 95% of
leaks.

I suspect it will be complicated to silence this false positive.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list
@ 2023-10-18  0:39 kernel test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kernel test robot @ 2023-10-18  0:39 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-testing
head:   5ab2ef71d3e0a4b8e5839b1850ccdd236695e2e0
commit: 6c9334e9230e552c795eebd34e6b208c6df693fe [21/23] parport: Use kasprintf() instead of fixed buffer formatting
:::::: branch date: 30 hours ago
:::::: commit date: 30 hours ago
config: i386-randconfig-141-20231017 (https://download.01.org/0day-ci/archive/20231018/202310180809.hepZB9k6-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231018/202310180809.hepZB9k6-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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202310180809.hepZB9k6-lkp@intel.com/

New smatch warnings:
drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list

Old smatch warnings:
drivers/parport/share.c:826 parport_register_dev_model() warn: possible memory leak of 'par_dev'

vim +486 drivers/parport/share.c

^1da177e4c3f41 Linus Torvalds      2005-04-16  404  
^1da177e4c3f41 Linus Torvalds      2005-04-16  405  /**
^1da177e4c3f41 Linus Torvalds      2005-04-16  406   *	parport_register_port - register a parallel port
^1da177e4c3f41 Linus Torvalds      2005-04-16  407   *	@base: base I/O address
^1da177e4c3f41 Linus Torvalds      2005-04-16  408   *	@irq: IRQ line
^1da177e4c3f41 Linus Torvalds      2005-04-16  409   *	@dma: DMA channel
^1da177e4c3f41 Linus Torvalds      2005-04-16  410   *	@ops: pointer to the port driver's port operations structure
^1da177e4c3f41 Linus Torvalds      2005-04-16  411   *
^1da177e4c3f41 Linus Torvalds      2005-04-16  412   *	When a parallel port (lowlevel) driver finds a port that
^1da177e4c3f41 Linus Torvalds      2005-04-16  413   *	should be made available to parallel port device drivers, it
^1da177e4c3f41 Linus Torvalds      2005-04-16  414   *	should call parport_register_port().  The @base, @irq, and
^1da177e4c3f41 Linus Torvalds      2005-04-16  415   *	@dma parameters are for the convenience of port drivers, and
^1da177e4c3f41 Linus Torvalds      2005-04-16  416   *	for ports where they aren't meaningful needn't be set to
^1da177e4c3f41 Linus Torvalds      2005-04-16  417   *	anything special.  They can be altered afterwards by adjusting
^1da177e4c3f41 Linus Torvalds      2005-04-16  418   *	the relevant members of the parport structure that is returned
^1da177e4c3f41 Linus Torvalds      2005-04-16  419   *	and represents the port.  They should not be tampered with
^1da177e4c3f41 Linus Torvalds      2005-04-16  420   *	after calling parport_announce_port, however.
^1da177e4c3f41 Linus Torvalds      2005-04-16  421   *
^1da177e4c3f41 Linus Torvalds      2005-04-16  422   *	If there are parallel port device drivers in the system that
^1da177e4c3f41 Linus Torvalds      2005-04-16  423   *	have registered themselves using parport_register_driver(),
^1da177e4c3f41 Linus Torvalds      2005-04-16  424   *	they are not told about the port at this time; that is done by
^1da177e4c3f41 Linus Torvalds      2005-04-16  425   *	parport_announce_port().
^1da177e4c3f41 Linus Torvalds      2005-04-16  426   *
^1da177e4c3f41 Linus Torvalds      2005-04-16  427   *	The @ops structure is allocated by the caller, and must not be
^1da177e4c3f41 Linus Torvalds      2005-04-16  428   *	deallocated before calling parport_remove_port().
^1da177e4c3f41 Linus Torvalds      2005-04-16  429   *
^1da177e4c3f41 Linus Torvalds      2005-04-16  430   *	If there is no memory to allocate a new parport structure,
^1da177e4c3f41 Linus Torvalds      2005-04-16  431   *	this function will return %NULL.
^1da177e4c3f41 Linus Torvalds      2005-04-16  432   **/
^1da177e4c3f41 Linus Torvalds      2005-04-16  433  
^1da177e4c3f41 Linus Torvalds      2005-04-16  434  struct parport *parport_register_port(unsigned long base, int irq, int dma,
^1da177e4c3f41 Linus Torvalds      2005-04-16  435  				      struct parport_operations *ops)
^1da177e4c3f41 Linus Torvalds      2005-04-16  436  {
^1da177e4c3f41 Linus Torvalds      2005-04-16  437  	struct list_head *l;
^1da177e4c3f41 Linus Torvalds      2005-04-16  438  	struct parport *tmp;
^1da177e4c3f41 Linus Torvalds      2005-04-16  439  	int num;
^1da177e4c3f41 Linus Torvalds      2005-04-16  440  	int device;
6fa45a22689722 Sudip Mukherjee     2015-05-20  441  	int ret;
^1da177e4c3f41 Linus Torvalds      2005-04-16  442  
c32df4e182e5bf Alexandru Gheorghiu 2013-07-03  443  	tmp = kzalloc(sizeof(struct parport), GFP_KERNEL);
47ec57ec0e5283 Sudip Mukherjee     2015-10-28  444  	if (!tmp)
^1da177e4c3f41 Linus Torvalds      2005-04-16  445  		return NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16  446  
^1da177e4c3f41 Linus Torvalds      2005-04-16  447  	/* Init our structure */
^1da177e4c3f41 Linus Torvalds      2005-04-16  448  	tmp->base = base;
^1da177e4c3f41 Linus Torvalds      2005-04-16  449  	tmp->irq = irq;
^1da177e4c3f41 Linus Torvalds      2005-04-16  450  	tmp->dma = dma;
^1da177e4c3f41 Linus Torvalds      2005-04-16  451  	tmp->muxport = tmp->daisy = tmp->muxsel = -1;
^1da177e4c3f41 Linus Torvalds      2005-04-16  452  	tmp->modes = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  453  	INIT_LIST_HEAD(&tmp->list);
^1da177e4c3f41 Linus Torvalds      2005-04-16  454  	tmp->devices = tmp->cad = NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16  455  	tmp->flags = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  456  	tmp->ops = ops;
^1da177e4c3f41 Linus Torvalds      2005-04-16  457  	tmp->physport = tmp;
^1da177e4c3f41 Linus Torvalds      2005-04-16  458  	memset(tmp->probe_info, 0, 5 * sizeof(struct parport_device_info));
^1da177e4c3f41 Linus Torvalds      2005-04-16  459  	rwlock_init(&tmp->cad_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  460  	spin_lock_init(&tmp->waitlist_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  461  	spin_lock_init(&tmp->pardevice_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  462  	tmp->ieee1284.mode = IEEE1284_MODE_COMPAT;
^1da177e4c3f41 Linus Torvalds      2005-04-16  463  	tmp->ieee1284.phase = IEEE1284_PH_FWD_IDLE;
a529f1505b6fac Thomas Gleixner     2010-09-07  464  	sema_init(&tmp->ieee1284.irq, 0);
^1da177e4c3f41 Linus Torvalds      2005-04-16  465  	tmp->spintime = parport_default_spintime;
^1da177e4c3f41 Linus Torvalds      2005-04-16  466  	atomic_set(&tmp->ref_count, 1);
^1da177e4c3f41 Linus Torvalds      2005-04-16  467  	INIT_LIST_HEAD(&tmp->full_list);
^1da177e4c3f41 Linus Torvalds      2005-04-16  468  
^1da177e4c3f41 Linus Torvalds      2005-04-16  469  	/* Search for the lowest free parport number. */
^1da177e4c3f41 Linus Torvalds      2005-04-16  470  
^1da177e4c3f41 Linus Torvalds      2005-04-16  471  	spin_lock(&full_list_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  472  	for (l = all_ports.next, num = 0; l != &all_ports; l = l->next, num++) {
^1da177e4c3f41 Linus Torvalds      2005-04-16  473  		struct parport *p = list_entry(l, struct parport, full_list);
^1da177e4c3f41 Linus Torvalds      2005-04-16  474  		if (p->number != num)
^1da177e4c3f41 Linus Torvalds      2005-04-16  475  			break;
^1da177e4c3f41 Linus Torvalds      2005-04-16  476  	}
^1da177e4c3f41 Linus Torvalds      2005-04-16  477  	tmp->portnum = tmp->number = num;
^1da177e4c3f41 Linus Torvalds      2005-04-16  478  	list_add_tail(&tmp->full_list, l);
^1da177e4c3f41 Linus Torvalds      2005-04-16  479  	spin_unlock(&full_list_lock);
^1da177e4c3f41 Linus Torvalds      2005-04-16  480  
^1da177e4c3f41 Linus Torvalds      2005-04-16  481  	/*
^1da177e4c3f41 Linus Torvalds      2005-04-16  482  	 * Now that the portnum is known finish doing the Init.
^1da177e4c3f41 Linus Torvalds      2005-04-16  483  	 */
6c9334e9230e55 Andy Shevchenko     2023-10-16  484  	tmp->name = kasprintf(GFP_KERNEL, "parport%d", tmp->portnum);
6c9334e9230e55 Andy Shevchenko     2023-10-16  485  	if (!tmp->name) {
6c9334e9230e55 Andy Shevchenko     2023-10-16 @486  		kfree(tmp);
6c9334e9230e55 Andy Shevchenko     2023-10-16  487  		return NULL;
6c9334e9230e55 Andy Shevchenko     2023-10-16  488  	}
6c9334e9230e55 Andy Shevchenko     2023-10-16  489  	dev_set_name(&tmp->bus_dev, tmp->name);
6fa45a22689722 Sudip Mukherjee     2015-05-20  490  	tmp->bus_dev.bus = &parport_bus_type;
6fa45a22689722 Sudip Mukherjee     2015-05-20  491  	tmp->bus_dev.release = free_port;
6fa45a22689722 Sudip Mukherjee     2015-05-20  492  	tmp->bus_dev.type = &parport_device_type;
^1da177e4c3f41 Linus Torvalds      2005-04-16  493  
^1da177e4c3f41 Linus Torvalds      2005-04-16  494  	for (device = 0; device < 5; device++)
^1da177e4c3f41 Linus Torvalds      2005-04-16  495  		/* assume the worst */
^1da177e4c3f41 Linus Torvalds      2005-04-16  496  		tmp->probe_info[device].class = PARPORT_CLASS_LEGACY;
^1da177e4c3f41 Linus Torvalds      2005-04-16  497  
^1da177e4c3f41 Linus Torvalds      2005-04-16  498  	tmp->waithead = tmp->waittail = NULL;
^1da177e4c3f41 Linus Torvalds      2005-04-16  499  
6fa45a22689722 Sudip Mukherjee     2015-05-20  500  	ret = device_register(&tmp->bus_dev);
6fa45a22689722 Sudip Mukherjee     2015-05-20  501  	if (ret) {
6fa45a22689722 Sudip Mukherjee     2015-05-20  502  		put_device(&tmp->bus_dev);
6fa45a22689722 Sudip Mukherjee     2015-05-20  503  		return NULL;
6fa45a22689722 Sudip Mukherjee     2015-05-20  504  	}
6fa45a22689722 Sudip Mukherjee     2015-05-20  505  
^1da177e4c3f41 Linus Torvalds      2005-04-16  506  	return tmp;
^1da177e4c3f41 Linus Torvalds      2005-04-16  507  }
27c6db26555029 Sudip Mukherjee     2015-10-28  508  EXPORT_SYMBOL(parport_register_port);
^1da177e4c3f41 Linus Torvalds      2005-04-16  509  

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-18 16:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18  9:57 [char-misc:char-misc-testing 21/23] drivers/parport/share.c:486 parport_register_port() warn: '&tmp->full_list' not removed from list Dan Carpenter
2023-10-18 12:39 ` Andy Shevchenko
2023-10-18 12:41   ` Dan Carpenter
2023-10-18 15:21   ` Andy Shevchenko
2023-10-18 16:57     ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2023-10-18  0:39 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.