[<prev] [next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.22.394.2312301017590.3057@hadrien>
Date: Sat, 30 Dec 2023 10:19:17 +0100 (CET)
From: Julia Lawall <julia.lawall@...ia.fr>
To: Rafał Miłecki <rafal@...ecki.pl>,
Miquel Raynal <miquel.raynal@...tlin.com>, linux-kernel@...r.kernel.org,
oe-kbuild-all@...ts.linux.dev
Subject: drivers/mtd/mtdcore.c:577:1-23: WARNING: Function "for_each_child_of_node"
should have of_node_put() before break around line 594. (fwd)
The of_node_put on line 598 should be moved just before the break on line
594.
julia
---------- Forwarded message ----------
Date: Fri, 29 Dec 2023 14:19:34 +0800
From: kernel test robot <lkp@...el.com>
To: oe-kbuild@...ts.linux.dev
Cc: lkp@...el.com, Julia Lawall <julia.lawall@...ia.fr>
Subject: drivers/mtd/mtdcore.c:577:1-23: WARNING: Function
"for_each_child_of_node" should have of_node_put() before break around line
594.
BCC: lkp@...el.com
CC: oe-kbuild-all@...ts.linux.dev
CC: linux-kernel@...r.kernel.org
TO: "Rafał Miłecki" <rafal@...ecki.pl>
CC: Miquel Raynal <miquel.raynal@...tlin.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8735c7c84d1bc5c3e481c02b6b6163bdefe4132f
commit: 2df11f00100d7278185a9dbefa20ba3f5d32401d mtd: core: try to find OF node for every MTD partition
date: 1 year, 2 months ago
:::::: branch date: 6 hours ago
:::::: commit date: 1 year, 2 months ago
config: loongarch-randconfig-r062-20231222 (https://download.01.org/0day-ci/archive/20231229/202312291448.6KecWcxf-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 13.2.0
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@...el.com>
| Reported-by: Julia Lawall <julia.lawall@...ia.fr>
| Closes: https://lore.kernel.org/r/202312291448.6KecWcxf-lkp@intel.com/
cocci warnings: (new ones prefixed by >>)
>> drivers/mtd/mtdcore.c:577:1-23: WARNING: Function "for_each_child_of_node" should have of_node_put() before break around line 594.
vim +/for_each_child_of_node +577 drivers/mtd/mtdcore.c
c4dfa25ab307a2 Alban Bedel 2018-11-13 548
ad9b10d1eaada1 Christian Marangi 2022-06-22 549 static void mtd_check_of_node(struct mtd_info *mtd)
ad9b10d1eaada1 Christian Marangi 2022-06-22 550 {
ad9b10d1eaada1 Christian Marangi 2022-06-22 551 struct device_node *partitions, *parent_dn, *mtd_dn = NULL;
ad9b10d1eaada1 Christian Marangi 2022-06-22 552 const char *pname, *prefix = "partition-";
ad9b10d1eaada1 Christian Marangi 2022-06-22 553 int plen, mtd_name_len, offset, prefix_len;
ad9b10d1eaada1 Christian Marangi 2022-06-22 554
ad9b10d1eaada1 Christian Marangi 2022-06-22 555 /* Check if MTD already has a device node */
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 556 if (mtd_get_of_node(mtd))
ad9b10d1eaada1 Christian Marangi 2022-06-22 557 return;
ad9b10d1eaada1 Christian Marangi 2022-06-22 558
7ec4cdb321738d Tetsuo Handa 2022-07-25 559 if (!mtd_is_partition(mtd))
7ec4cdb321738d Tetsuo Handa 2022-07-25 560 return;
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 561
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 562 parent_dn = of_node_get(mtd_get_of_node(mtd->parent));
ad9b10d1eaada1 Christian Marangi 2022-06-22 563 if (!parent_dn)
ad9b10d1eaada1 Christian Marangi 2022-06-22 564 return;
ad9b10d1eaada1 Christian Marangi 2022-06-22 565
2df11f00100d72 Rafał Miłecki 2022-10-04 566 if (mtd_is_partition(mtd->parent))
2df11f00100d72 Rafał Miłecki 2022-10-04 567 partitions = of_node_get(parent_dn);
2df11f00100d72 Rafał Miłecki 2022-10-04 568 else
ad9b10d1eaada1 Christian Marangi 2022-06-22 569 partitions = of_get_child_by_name(parent_dn, "partitions");
ad9b10d1eaada1 Christian Marangi 2022-06-22 570 if (!partitions)
ad9b10d1eaada1 Christian Marangi 2022-06-22 571 goto exit_parent;
ad9b10d1eaada1 Christian Marangi 2022-06-22 572
ad9b10d1eaada1 Christian Marangi 2022-06-22 573 prefix_len = strlen(prefix);
ad9b10d1eaada1 Christian Marangi 2022-06-22 574 mtd_name_len = strlen(mtd->name);
ad9b10d1eaada1 Christian Marangi 2022-06-22 575
ad9b10d1eaada1 Christian Marangi 2022-06-22 576 /* Search if a partition is defined with the same name */
ad9b10d1eaada1 Christian Marangi 2022-06-22 @577 for_each_child_of_node(partitions, mtd_dn) {
ad9b10d1eaada1 Christian Marangi 2022-06-22 578 /* Skip partition with no/wrong prefix */
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 579 if (!of_node_name_prefix(mtd_dn, prefix))
ad9b10d1eaada1 Christian Marangi 2022-06-22 580 continue;
ad9b10d1eaada1 Christian Marangi 2022-06-22 581
ad9b10d1eaada1 Christian Marangi 2022-06-22 582 /* Label have priority. Check that first */
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 583 if (!of_property_read_string(mtd_dn, "label", &pname)) {
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 584 offset = 0;
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 585 } else {
c5f5d0cd40e3bc Rafał Miłecki 2022-10-04 586 pname = mtd_dn->name;
ad9b10d1eaada1 Christian Marangi 2022-06-22 587 offset = prefix_len;
ad9b10d1eaada1 Christian Marangi 2022-06-22 588 }
ad9b10d1eaada1 Christian Marangi 2022-06-22 589
ad9b10d1eaada1 Christian Marangi 2022-06-22 590 plen = strlen(pname) - offset;
ad9b10d1eaada1 Christian Marangi 2022-06-22 591 if (plen == mtd_name_len &&
ad9b10d1eaada1 Christian Marangi 2022-06-22 592 !strncmp(mtd->name, pname + offset, plen)) {
2df11f00100d72 Rafał Miłecki 2022-10-04 593 mtd_set_of_node(mtd, mtd_dn);
ad9b10d1eaada1 Christian Marangi 2022-06-22 @594 break;
ad9b10d1eaada1 Christian Marangi 2022-06-22 595 }
ad9b10d1eaada1 Christian Marangi 2022-06-22 596 }
ad9b10d1eaada1 Christian Marangi 2022-06-22 597
ad9b10d1eaada1 Christian Marangi 2022-06-22 598 of_node_put(partitions);
ad9b10d1eaada1 Christian Marangi 2022-06-22 599 exit_parent:
ad9b10d1eaada1 Christian Marangi 2022-06-22 600 of_node_put(parent_dn);
ad9b10d1eaada1 Christian Marangi 2022-06-22 601 }
ad9b10d1eaada1 Christian Marangi 2022-06-22 602
:::::: The code at line 577 was first introduced by commit
:::::: ad9b10d1eaada169bd764abcab58f08538877e26 mtd: core: introduce of support for dynamic partitions
:::::: TO: Christian Marangi <ansuelsmth@...il.com>
:::::: CC: Miquel Raynal <miquel.raynal@...tlin.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists