drivers/auxdisplay/line-display.c:89 delete_attachment() warn: iterator used outside loop: 'attachment'

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: "Jean-François Lessard" <[email protected]>
CC: Andy Shevchenko <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   0d839570765118029aa8bf4a95444c6a11aacf85
commit: 3ba5c78fe7c5d60edae0c47361f191d40c5c1cf0 auxdisplay: linedisp: support attribute attachment to auxdisplay devices
date:   10 months ago
:::::: branch date: 25 hours ago
:::::: commit date: 10 months ago
config: x86_64-randconfig-161 (https://download.01.org/0day-ci/archive/20260807/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9187-g5189e3fb

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
| Fixes: 3ba5c78fe7c5 ("auxdisplay: linedisp: support attribute attachment to auxdisplay devices")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/auxdisplay/line-display.c:89 delete_attachment() warn: iterator used outside loop: 'attachment'

Old smatch warnings:
drivers/auxdisplay/line-display.c:110 to_linedisp() warn: iterator used outside loop: 'attachment'

vim +/attachment +89 drivers/auxdisplay/line-display.c

3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  72  
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  73  static struct linedisp *delete_attachment(struct device *dev, bool direct)
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  74  {
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  75  	struct linedisp_attachment *attachment;
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  76  	struct linedisp *linedisp;
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  77  
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  78  	guard(spinlock)(&linedisp_attachments_lock);
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  79  
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  80  	list_for_each_entry(attachment, &linedisp_attachments, list) {
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  81  		if (attachment->device == dev &&
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  82  		    attachment->direct == direct)
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  83  			break;
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  84  	}
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  85  
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  86  	if (list_entry_is_head(attachment, &linedisp_attachments, list))
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  87  		return NULL;
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  88  
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18 @89  	linedisp = attachment->linedisp;
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  90  	list_del(&attachment->list);
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  91  	kfree(attachment);
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  92  
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  93  	return linedisp;
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  94  }
3ba5c78fe7c5d6 Jean-François Lessard 2025-09-18  95  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.