Skip to contentSkip to conversation

drivers/nvmem/core.c:462:8-12: ERROR: invalid reference to the index variable of the iterator on line 456 (fwd)

PATCH In review Julia Lawall 3 participants 3 messages Apr 17, 2020 – Apr 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drivers/nvmem/core.c:462:8-12: ERROR: invalid reference to the index variable of the iterator on line 456 (fwd)

If the iteration on line 456 reaches the end of the list, cell will be an invalid value somewhere in the middle of or above the list head.

The initialization of cell to NULL is also unnecessary, since no one will ever see that value.

This seems to be quite old code. I don't know why the error is showing up now

julia

---------- Forwarded message ----------
Date: Fri, 17 Apr 2020 10:44:42 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: lkp(a)intel.com, Julia Lawall <[email protected]>
Subject: [android-common:android-4.19 1/3] drivers/nvmem/core.c:462:8-12: ERROR:
invalid reference to the index variable of the iterator on line 456

CC: kbuild-all(a)lists.01.org
TO: cros-kernel-buildreports(a)googlegroups.com

tree:   https://android.googlesource.com/kernel/common android-4.19
head:   824a6c4cdf73abdd188b5a1e55fba7c63e18ea81
commit: 0fc0aae624eca1b9f56a962628c36b8b8829afa0 [1/3] BACKPORT: nvmem: resolve cells from DT at registration time

:::::: branch date: 7 weeks ago
:::::: commit date: 7 weeks ago

If you fix the issue, kindly add following tag as appropriate

coccinelle warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/nvmem/core.c:462:8-12: ERROR: invalid reference to the index variable of the iterator on line 456

git remote add android-common https://android.googlesource.com/kernel/common
git remote update android-common
git checkout 0fc0aae624eca1b9f56a962628c36b8b8829afa0
vim +462 drivers/nvmem/core.c

b6c217ab9be689 Andrew Lunn         2016-02-26  448
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  449  static struct nvmem_cell *
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  450  nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index)
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  451  {
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  452  	struct nvmem_cell *cell = NULL;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  453  	int i = 0;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  454
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  455  	mutex_lock(&nvmem_mutex);
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 @456  	list_for_each_entry(cell, &nvmem_cells, node) {
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  457  		if (index == i++)
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  458  			break;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  459  	}
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  460  	mutex_unlock(&nvmem_mutex);

0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 461
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 @462 return cell;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 463 } 0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 464

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

#1 lore raw

+Mark Salyzyn

Julia,

Thanks for the analysis. It probably popped up in 0-day because this patch was recently cherry-picked into the android-4.19 branch.

-Todd

Quoted 69 lines · Julia Lawall

If the iteration on line 456 reaches the end of the list, cell will be an invalid value somewhere in the middle of or above the list head.

The initialization of cell to NULL is also unnecessary, since no one will ever see that value.

This seems to be quite old code. I don't know why the error is showing up now

julia

---------- Forwarded message ----------
Date: Fri, 17 Apr 2020 10:44:42 +0800
From: kbuild test robot <[email protected]>
To: kbuild(a)lists.01.org
Cc: lkp(a)intel.com, Julia Lawall <[email protected]>
Subject: [android-common:android-4.19 1/3] drivers/nvmem/core.c:462:8-12: ERROR:
invalid reference to the index variable of the iterator on line 456

CC: kbuild-all(a)lists.01.org
TO: cros-kernel-buildreports(a)googlegroups.com

tree:   https://android.googlesource.com/kernel/common android-4.19
head:   824a6c4cdf73abdd188b5a1e55fba7c63e18ea81
commit: 0fc0aae624eca1b9f56a962628c36b8b8829afa0 [1/3] BACKPORT: nvmem: resolve cells from DT at registration time

:::::: branch date: 7 weeks ago
:::::: commit date: 7 weeks ago

If you fix the issue, kindly add following tag as appropriate

coccinelle warnings: (new ones prefixed by >>)

Quoted 1 line
Quoted 1 line

drivers/nvmem/core.c:462:8-12: ERROR: invalid reference to the index variable of the iterator on line 456

git remote add android-common https://android.googlesource.com/kernel/common
git remote update android-common
git checkout 0fc0aae624eca1b9f56a962628c36b8b8829afa0
vim +462 drivers/nvmem/core.c

b6c217ab9be689 Andrew Lunn         2016-02-26  448
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  449  static struct nvmem_cell *
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  450  nvmem_find_cell_by_index(struct nvmem_device *nvmem, int index)
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  451  {
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  452      struct nvmem_cell *cell = NULL;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  453      int i = 0;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  454
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  455      mutex_lock(&nvmem_mutex);
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 @456      list_for_each_entry(cell, &nvmem_cells, node) {
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  457              if (index == i++)
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  458                      break;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  459      }
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  460      mutex_unlock(&nvmem_mutex);
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21  461

0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 @462 return cell;
0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 463 } 0fc0aae624eca1 Bartosz Golaszewski 2018-09-21 464

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

--
You received this message because you are subscribed to the Google Groups "cros-kernel-buildreports" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cros-kernel-buildreports+unsubscribe(a)googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cros-kernel-buildreports/alpine.DEB.2.21.2004171901260.4325%40hadrien.

#2 lore raw

pt., 17 kwi 2020 o 19:12 Todd Kjos <[email protected]> napisał(a):

Quoted 10 lines

+Mark Salyzyn

Julia,

Thanks for the analysis. It probably popped up in 0-day because this patch was recently cherry-picked into the android-4.19 branch.

-Todd

FYI The fix for this is upstream commit 0749aa25af82c ("nvmem: core:
fix regression in of_nvmem_cell_get()").

Bart