Kernel
Threads by month
- ----- 2025 -----
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- 55 participants
- 16941 discussions

[openeuler:OLK-6.6 1899/1899] mm/dynamic_pool.c:1612:51: warning: variable 'ret' is uninitialized when used here
by kernel test robot 08 Feb '25
by kernel test robot 08 Feb '25
08 Feb '25
Hi Liu,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git OLK-6.6
head: 8673e7441a723dd5e885e372a4d0351658286304
commit: cf98ffbc116bc49dc4506c68e20b02e26519ad35 [1899/1899] mm/dynamic_pool: fill dpool with pagelist
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20250208/202502081751.f1v777Vf-lkp@…)
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/20250208/202502081751.f1v777Vf-lkp@…)
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(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502081751.f1v777Vf-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from mm/dynamic_pool.c:10:
In file included from include/linux/memblock.h:12:
In file included from include/linux/mm.h:2181:
include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
508 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
509 | item];
| ~~~~
include/linux/vmstat.h:515:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
515 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
516 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:527:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
527 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
528 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:536:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
536 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
537 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
mm/dynamic_pool.c:836:6: warning: variable 'type' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
836 | if (!dpool->online)
| ^~~~~~~~~~~~~~
mm/dynamic_pool.c:865:36: note: uninitialized use occurs here
865 | trace_dpool_alloc_hugepage(dpool, type, folio, pool->free_huge_pages,
| ^~~~
mm/dynamic_pool.c:836:2: note: remove the 'if' if its condition is always false
836 | if (!dpool->online)
| ^~~~~~~~~~~~~~~~~~~
837 | goto unlock;
| ~~~~~~~~~~~
mm/dynamic_pool.c:826:10: note: initialize the variable 'type' to silence this warning
826 | int type;
| ^
| = 0
mm/dynamic_pool.c:836:6: warning: variable 'pool' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
836 | if (!dpool->online)
| ^~~~~~~~~~~~~~
mm/dynamic_pool.c:865:49: note: uninitialized use occurs here
865 | trace_dpool_alloc_hugepage(dpool, type, folio, pool->free_huge_pages,
| ^~~~
mm/dynamic_pool.c:836:2: note: remove the 'if' if its condition is always false
836 | if (!dpool->online)
| ^~~~~~~~~~~~~~~~~~~
837 | goto unlock;
| ~~~~~~~~~~~
mm/dynamic_pool.c:823:25: note: initialize the variable 'pool' to silence this warning
823 | struct pages_pool *pool;
| ^
| = NULL
>> mm/dynamic_pool.c:1612:51: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
1612 | pr_err("init failed, create failed. ret: %d\n", ret);
| ^~~
include/linux/printk.h:498:33: note: expanded from macro 'pr_err'
498 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~
include/linux/printk.h:455:60: note: expanded from macro 'printk'
455 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__)
| ^~~~~~~~~~~
include/linux/printk.h:427:19: note: expanded from macro 'printk_index_wrap'
427 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~~~~~~~~
mm/dynamic_pool.c:1586:9: note: initialize the variable 'ret' to silence this warning
1586 | int ret;
| ^
| = 0
8 warnings generated.
vim +/ret +1612 mm/dynamic_pool.c
1582
1583 int dpool_init(struct dpool_info *arg)
1584 {
1585 struct dynamic_pool *dpool;
1586 int ret;
1587
1588 if (!dpool_enabled)
1589 return -EINVAL;
1590
1591 if (!arg || !arg->memcg || arg->range_cnt <= 0) {
1592 pr_err("init failed, arg is invalid\n");
1593 return -EINVAL;
1594 }
1595
1596 mutex_lock(&dpool_mutex);
1597
1598 if (dpool_global_pool || arg->memcg->dpool) {
1599 pr_err("init failed, dpool is already exist\n");
1600 ret = -EINVAL;
1601 goto unlock;
1602 }
1603
1604 if (!(arg->memcg->css.cgroup->self.flags & CSS_ONLINE)) {
1605 pr_err("init failed, memcg is not online\n");
1606 ret = -EINVAL;
1607 goto unlock;
1608 }
1609
1610 dpool = dpool_create(arg->memcg, &pagelist_dpool_ops);
1611 if (!dpool) {
> 1612 pr_err("init failed, create failed. ret: %d\n", ret);
1613 ret = -ENOMEM;
1614 goto unlock;
1615 }
1616
1617 dpool_global_pool = dpool;
1618
1619 BUG_ON(!dpool->ops->fill_pool);
1620 ret = dpool->ops->fill_pool(dpool, arg);
1621 if (ret)
1622 dpool_put(dpool);
1623
1624 unlock:
1625 mutex_unlock(&dpool_mutex);
1626
1627 return ret;
1628 }
1629
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[openeuler:OLK-5.10 2729/2729] mm/khugepaged.c:1646: warning: Function parameter or member 'reliable' not described in 'collapse_file'
by kernel test robot 08 Feb '25
by kernel test robot 08 Feb '25
08 Feb '25
tree: https://gitee.com/openeuler/kernel.git OLK-5.10
head: d446fe23ba300d0cceac22dff0e7e9a8d21646e1
commit: 6263994761a3d3ad6e5fa3beff9ca8cbd38d3bf3 [2729/2729] mm: thp: Add memory reliable support for hugepaged collapse
config: x86_64-buildonly-randconfig-002-20250208 (https://download.01.org/0day-ci/archive/20250208/202502081316.Lfy85pbg-lkp@…)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250208/202502081316.Lfy85pbg-lkp@…)
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(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502081316.Lfy85pbg-lkp@intel.com/
All warnings (new ones prefixed by >>):
mm/khugepaged.c:102: warning: Function parameter or member 'nr_pte_mapped_thp' not described in 'mm_slot'
mm/khugepaged.c:102: warning: Function parameter or member 'pte_mapped_thp' not described in 'mm_slot'
mm/khugepaged.c:1443: warning: Function parameter or member 'mm' not described in 'collapse_pte_mapped_thp'
mm/khugepaged.c:1443: warning: Function parameter or member 'addr' not described in 'collapse_pte_mapped_thp'
mm/khugepaged.c:1646: warning: Function parameter or member 'mm' not described in 'collapse_file'
mm/khugepaged.c:1646: warning: Function parameter or member 'file' not described in 'collapse_file'
mm/khugepaged.c:1646: warning: Function parameter or member 'start' not described in 'collapse_file'
mm/khugepaged.c:1646: warning: Function parameter or member 'hpage' not described in 'collapse_file'
mm/khugepaged.c:1646: warning: Function parameter or member 'node' not described in 'collapse_file'
>> mm/khugepaged.c:1646: warning: Function parameter or member 'reliable' not described in 'collapse_file'
vim +1646 mm/khugepaged.c
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1623
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1624 /**
99cb0dbd47a15d Song Liu 2019-09-23 1625 * collapse_file - collapse filemap/tmpfs/shmem pages into huge one.
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1626 *
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1627 * Basic scheme is simple, details are more complex:
87c460a0bded56 Hugh Dickins 2018-11-30 1628 * - allocate and lock a new huge page;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1629 * - scan page cache replacing old pages with the new one
99cb0dbd47a15d Song Liu 2019-09-23 1630 * + swap/gup in pages if necessary;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1631 * + fill in gaps;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1632 * + keep old pages around in case rollback is required;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1633 * - if replacing succeeds:
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1634 * + copy data over;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1635 * + free old pages;
87c460a0bded56 Hugh Dickins 2018-11-30 1636 * + unlock huge page;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1637 * - if replacing failed;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1638 * + put all pages back and unfreeze them;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1639 * + restore gaps in the page cache;
87c460a0bded56 Hugh Dickins 2018-11-30 1640 * + unlock and free huge page;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1641 */
579c571e2efdb8 Song Liu 2019-09-23 1642 static void collapse_file(struct mm_struct *mm,
579c571e2efdb8 Song Liu 2019-09-23 1643 struct file *file, pgoff_t start,
6263994761a3d3 Ma Wupeng 2022-11-11 1644 struct page **hpage, int node,
6263994761a3d3 Ma Wupeng 2022-11-11 1645 bool reliable)
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 @1646 {
579c571e2efdb8 Song Liu 2019-09-23 1647 struct address_space *mapping = file->f_mapping;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1648 gfp_t gfp;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1649 struct page *new_page;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1650 pgoff_t index, end = start + HPAGE_PMD_NR;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1651 LIST_HEAD(pagelist);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1652 XA_STATE_ORDER(xas, &mapping->i_pages, start, HPAGE_PMD_ORDER);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1653 int nr_none = 0, result = SCAN_SUCCEED;
99cb0dbd47a15d Song Liu 2019-09-23 1654 bool is_shmem = shmem_file(file);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1655
99cb0dbd47a15d Song Liu 2019-09-23 1656 VM_BUG_ON(!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && !is_shmem);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1657 VM_BUG_ON(start & (HPAGE_PMD_NR - 1));
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1658
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1659 /* Only allocate from the target node */
41b6167e8f746b Michal Hocko 2017-01-10 1660 gfp = alloc_hugepage_khugepaged_gfpmask() | __GFP_THISNODE;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1661
6263994761a3d3 Ma Wupeng 2022-11-11 1662 if (reliable)
6263994761a3d3 Ma Wupeng 2022-11-11 1663 gfp |= GFP_RELIABLE;
6263994761a3d3 Ma Wupeng 2022-11-11 1664
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1665 new_page = khugepaged_alloc_page(hpage, gfp, node);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1666 if (!new_page) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1667 result = SCAN_ALLOC_HUGE_PAGE_FAIL;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1668 goto out;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1669 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1670
d9eb1ea2bf8734 Johannes Weiner 2020-06-03 1671 if (unlikely(mem_cgroup_charge(new_page, mm, gfp))) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1672 result = SCAN_CGROUP_CHARGE_FAIL;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1673 goto out;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1674 }
9d82c69438d0df Johannes Weiner 2020-06-03 1675 count_memcg_page_event(new_page, THP_COLLAPSE_ALLOC);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1676
95feeabb77149f Hugh Dickins 2018-11-30 1677 /* This will be less messy when we use multi-index entries */
95feeabb77149f Hugh Dickins 2018-11-30 1678 do {
95feeabb77149f Hugh Dickins 2018-11-30 1679 xas_lock_irq(&xas);
95feeabb77149f Hugh Dickins 2018-11-30 1680 xas_create_range(&xas);
95feeabb77149f Hugh Dickins 2018-11-30 1681 if (!xas_error(&xas))
95feeabb77149f Hugh Dickins 2018-11-30 1682 break;
95feeabb77149f Hugh Dickins 2018-11-30 1683 xas_unlock_irq(&xas);
95feeabb77149f Hugh Dickins 2018-11-30 1684 if (!xas_nomem(&xas, GFP_KERNEL)) {
95feeabb77149f Hugh Dickins 2018-11-30 1685 result = SCAN_FAIL;
95feeabb77149f Hugh Dickins 2018-11-30 1686 goto out;
95feeabb77149f Hugh Dickins 2018-11-30 1687 }
95feeabb77149f Hugh Dickins 2018-11-30 1688 } while (1);
95feeabb77149f Hugh Dickins 2018-11-30 1689
042a30824871fa Hugh Dickins 2018-11-30 1690 __SetPageLocked(new_page);
99cb0dbd47a15d Song Liu 2019-09-23 1691 if (is_shmem)
042a30824871fa Hugh Dickins 2018-11-30 1692 __SetPageSwapBacked(new_page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1693 new_page->index = start;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1694 new_page->mapping = mapping;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1695
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1696 /*
87c460a0bded56 Hugh Dickins 2018-11-30 1697 * At this point the new_page is locked and not up-to-date.
87c460a0bded56 Hugh Dickins 2018-11-30 1698 * It's safe to insert it into the page cache, because nobody would
87c460a0bded56 Hugh Dickins 2018-11-30 1699 * be able to map it or use it in another way until we unlock it.
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1700 */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1701
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1702 xas_set(&xas, start);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1703 for (index = start; index < end; index++) {
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1704 struct page *page = xas_next(&xas);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1705
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1706 VM_BUG_ON(index != xas.xa_index);
99cb0dbd47a15d Song Liu 2019-09-23 1707 if (is_shmem) {
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1708 if (!page) {
701270fa193aad Hugh Dickins 2018-11-30 1709 /*
99cb0dbd47a15d Song Liu 2019-09-23 1710 * Stop if extent has been truncated or
99cb0dbd47a15d Song Liu 2019-09-23 1711 * hole-punched, and is now completely
99cb0dbd47a15d Song Liu 2019-09-23 1712 * empty.
701270fa193aad Hugh Dickins 2018-11-30 1713 */
701270fa193aad Hugh Dickins 2018-11-30 1714 if (index == start) {
701270fa193aad Hugh Dickins 2018-11-30 1715 if (!xas_next_entry(&xas, end - 1)) {
701270fa193aad Hugh Dickins 2018-11-30 1716 result = SCAN_TRUNCATED;
042a30824871fa Hugh Dickins 2018-11-30 1717 goto xa_locked;
701270fa193aad Hugh Dickins 2018-11-30 1718 }
701270fa193aad Hugh Dickins 2018-11-30 1719 xas_set(&xas, index);
701270fa193aad Hugh Dickins 2018-11-30 1720 }
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1721 if (!shmem_charge(mapping->host, 1)) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1722 result = SCAN_FAIL;
042a30824871fa Hugh Dickins 2018-11-30 1723 goto xa_locked;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1724 }
4101196b19d7f9 Matthew Wilcox (Oracle 2019-09-23 1725) xas_store(&xas, new_page);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1726 nr_none++;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1727 continue;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1728 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1729
3159f943aafdba Matthew Wilcox 2017-11-03 1730 if (xa_is_value(page) || !PageUptodate(page)) {
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1731 xas_unlock_irq(&xas);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1732 /* swap in or instantiate fallocated page */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1733 if (shmem_getpage(mapping->host, index, &page,
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1734 SGP_NOHUGE)) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1735 result = SCAN_FAIL;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1736 goto xa_unlocked;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1737 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1738 } else if (trylock_page(page)) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1739 get_page(page);
042a30824871fa Hugh Dickins 2018-11-30 1740 xas_unlock_irq(&xas);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1741 } else {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1742 result = SCAN_PAGE_LOCK;
042a30824871fa Hugh Dickins 2018-11-30 1743 goto xa_locked;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1744 }
99cb0dbd47a15d Song Liu 2019-09-23 1745 } else { /* !is_shmem */
99cb0dbd47a15d Song Liu 2019-09-23 1746 if (!page || xa_is_value(page)) {
99cb0dbd47a15d Song Liu 2019-09-23 1747 xas_unlock_irq(&xas);
99cb0dbd47a15d Song Liu 2019-09-23 1748 page_cache_sync_readahead(mapping, &file->f_ra,
99cb0dbd47a15d Song Liu 2019-09-23 1749 file, index,
e5a59d308f52bb David Howells 2020-09-04 1750 end - index);
99cb0dbd47a15d Song Liu 2019-09-23 1751 /* drain pagevecs to help isolate_lru_page() */
99cb0dbd47a15d Song Liu 2019-09-23 1752 lru_add_drain();
99cb0dbd47a15d Song Liu 2019-09-23 1753 page = find_lock_page(mapping, index);
99cb0dbd47a15d Song Liu 2019-09-23 1754 if (unlikely(page == NULL)) {
99cb0dbd47a15d Song Liu 2019-09-23 1755 result = SCAN_FAIL;
99cb0dbd47a15d Song Liu 2019-09-23 1756 goto xa_unlocked;
99cb0dbd47a15d Song Liu 2019-09-23 1757 }
75f360696ce9d8 Song Liu 2019-11-30 1758 } else if (PageDirty(page)) {
75f360696ce9d8 Song Liu 2019-11-30 1759 /*
75f360696ce9d8 Song Liu 2019-11-30 1760 * khugepaged only works on read-only fd,
75f360696ce9d8 Song Liu 2019-11-30 1761 * so this page is dirty because it hasn't
75f360696ce9d8 Song Liu 2019-11-30 1762 * been flushed since first write. There
75f360696ce9d8 Song Liu 2019-11-30 1763 * won't be new dirty pages.
75f360696ce9d8 Song Liu 2019-11-30 1764 *
75f360696ce9d8 Song Liu 2019-11-30 1765 * Trigger async flush here and hope the
75f360696ce9d8 Song Liu 2019-11-30 1766 * writeback is done when khugepaged
75f360696ce9d8 Song Liu 2019-11-30 1767 * revisits this page.
75f360696ce9d8 Song Liu 2019-11-30 1768 *
75f360696ce9d8 Song Liu 2019-11-30 1769 * This is a one-off situation. We are not
75f360696ce9d8 Song Liu 2019-11-30 1770 * forcing writeback in loop.
75f360696ce9d8 Song Liu 2019-11-30 1771 */
75f360696ce9d8 Song Liu 2019-11-30 1772 xas_unlock_irq(&xas);
75f360696ce9d8 Song Liu 2019-11-30 1773 filemap_flush(mapping);
75f360696ce9d8 Song Liu 2019-11-30 1774 result = SCAN_FAIL;
75f360696ce9d8 Song Liu 2019-11-30 1775 goto xa_unlocked;
ca1ab8b4a53297 Rongwei Wang 2021-11-15 1776 } else if (PageWriteback(page)) {
ca1ab8b4a53297 Rongwei Wang 2021-11-15 1777 xas_unlock_irq(&xas);
ca1ab8b4a53297 Rongwei Wang 2021-11-15 1778 result = SCAN_FAIL;
ca1ab8b4a53297 Rongwei Wang 2021-11-15 1779 goto xa_unlocked;
99cb0dbd47a15d Song Liu 2019-09-23 1780 } else if (trylock_page(page)) {
99cb0dbd47a15d Song Liu 2019-09-23 1781 get_page(page);
99cb0dbd47a15d Song Liu 2019-09-23 1782 xas_unlock_irq(&xas);
99cb0dbd47a15d Song Liu 2019-09-23 1783 } else {
99cb0dbd47a15d Song Liu 2019-09-23 1784 result = SCAN_PAGE_LOCK;
99cb0dbd47a15d Song Liu 2019-09-23 1785 goto xa_locked;
99cb0dbd47a15d Song Liu 2019-09-23 1786 }
99cb0dbd47a15d Song Liu 2019-09-23 1787 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1788
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1789 /*
b93b016313b3ba Matthew Wilcox 2018-04-10 1790 * The page must be locked, so we can drop the i_pages lock
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1791 * without racing with truncate.
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1792 */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1793 VM_BUG_ON_PAGE(!PageLocked(page), page);
4655e5e5f38726 Song Liu 2019-11-15 1794
4655e5e5f38726 Song Liu 2019-11-15 1795 /* make sure the page is up to date */
4655e5e5f38726 Song Liu 2019-11-15 1796 if (unlikely(!PageUptodate(page))) {
4655e5e5f38726 Song Liu 2019-11-15 1797 result = SCAN_FAIL;
4655e5e5f38726 Song Liu 2019-11-15 1798 goto out_unlock;
4655e5e5f38726 Song Liu 2019-11-15 1799 }
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1800
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1801 /*
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1802 * If file was truncated then extended, or hole-punched, before
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1803 * we locked the first page, then a THP might be there already.
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1804 */
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1805 if (PageTransCompound(page)) {
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1806 result = SCAN_PAGE_COMPOUND;
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1807 goto out_unlock;
06a5e1268a5fb9 Hugh Dickins 2018-11-30 1808 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1809
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1810 if (page_mapping(page) != mapping) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1811 result = SCAN_TRUNCATED;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1812 goto out_unlock;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1813 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1814
ca1ab8b4a53297 Rongwei Wang 2021-11-15 1815 if (!is_shmem && (PageDirty(page) ||
ca1ab8b4a53297 Rongwei Wang 2021-11-15 1816 PageWriteback(page))) {
4655e5e5f38726 Song Liu 2019-11-15 1817 /*
4655e5e5f38726 Song Liu 2019-11-15 1818 * khugepaged only works on read-only fd, so this
4655e5e5f38726 Song Liu 2019-11-15 1819 * page is dirty because it hasn't been flushed
4655e5e5f38726 Song Liu 2019-11-15 1820 * since first write.
4655e5e5f38726 Song Liu 2019-11-15 1821 */
4655e5e5f38726 Song Liu 2019-11-15 1822 result = SCAN_FAIL;
4655e5e5f38726 Song Liu 2019-11-15 1823 goto out_unlock;
4655e5e5f38726 Song Liu 2019-11-15 1824 }
4655e5e5f38726 Song Liu 2019-11-15 1825
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1826 if (isolate_lru_page(page)) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1827 result = SCAN_DEL_PAGE_LRU;
042a30824871fa Hugh Dickins 2018-11-30 1828 goto out_unlock;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1829 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1830
99cb0dbd47a15d Song Liu 2019-09-23 1831 if (page_has_private(page) &&
99cb0dbd47a15d Song Liu 2019-09-23 1832 !try_to_release_page(page, GFP_KERNEL)) {
99cb0dbd47a15d Song Liu 2019-09-23 1833 result = SCAN_PAGE_HAS_PRIVATE;
2f33a706027c94 Hugh Dickins 2020-05-27 1834 putback_lru_page(page);
99cb0dbd47a15d Song Liu 2019-09-23 1835 goto out_unlock;
99cb0dbd47a15d Song Liu 2019-09-23 1836 }
99cb0dbd47a15d Song Liu 2019-09-23 1837
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1838 if (page_mapped(page))
977fbdcd5986c9 Matthew Wilcox 2018-01-31 1839 unmap_mapping_pages(mapping, index, 1, false);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1840
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1841 xas_lock_irq(&xas);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1842 xas_set(&xas, index);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1843
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1844 VM_BUG_ON_PAGE(page != xas_load(&xas), page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1845 VM_BUG_ON_PAGE(page_mapped(page), page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1846
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1847 /*
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1848 * The page is expected to have page_count() == 3:
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1849 * - we hold a pin on it;
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1850 * - one reference from page cache;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1851 * - one from isolate_lru_page;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1852 */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1853 if (!page_ref_freeze(page, 3)) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1854 result = SCAN_PAGE_COUNT;
042a30824871fa Hugh Dickins 2018-11-30 1855 xas_unlock_irq(&xas);
042a30824871fa Hugh Dickins 2018-11-30 1856 putback_lru_page(page);
042a30824871fa Hugh Dickins 2018-11-30 1857 goto out_unlock;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1858 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1859
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1860 /*
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1861 * Add the page to the list to be able to undo the collapse if
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1862 * something go wrong.
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1863 */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1864 list_add_tail(&page->lru, &pagelist);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1865
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1866 /* Finally, replace with the new page. */
4101196b19d7f9 Matthew Wilcox (Oracle 2019-09-23 1867) xas_store(&xas, new_page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1868 continue;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1869 out_unlock:
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1870 unlock_page(page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1871 put_page(page);
042a30824871fa Hugh Dickins 2018-11-30 1872 goto xa_unlocked;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1873 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1874
99cb0dbd47a15d Song Liu 2019-09-23 1875 if (is_shmem)
042a30824871fa Hugh Dickins 2018-11-30 1876 __inc_node_page_state(new_page, NR_SHMEM_THPS);
09d91cda0e8207 Song Liu 2019-09-23 1877 else {
99cb0dbd47a15d Song Liu 2019-09-23 1878 __inc_node_page_state(new_page, NR_FILE_THPS);
09d91cda0e8207 Song Liu 2019-09-23 1879 filemap_nr_thps_inc(mapping);
09d91cda0e8207 Song Liu 2019-09-23 1880 }
99cb0dbd47a15d Song Liu 2019-09-23 1881
042a30824871fa Hugh Dickins 2018-11-30 1882 if (nr_none) {
9d82c69438d0df Johannes Weiner 2020-06-03 1883 __mod_lruvec_page_state(new_page, NR_FILE_PAGES, nr_none);
99cb0dbd47a15d Song Liu 2019-09-23 1884 if (is_shmem)
9d82c69438d0df Johannes Weiner 2020-06-03 1885 __mod_lruvec_page_state(new_page, NR_SHMEM, nr_none);
042a30824871fa Hugh Dickins 2018-11-30 1886 }
042a30824871fa Hugh Dickins 2018-11-30 1887
042a30824871fa Hugh Dickins 2018-11-30 1888 xa_locked:
042a30824871fa Hugh Dickins 2018-11-30 1889 xas_unlock_irq(&xas);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1890 xa_unlocked:
042a30824871fa Hugh Dickins 2018-11-30 1891
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1892 if (result == SCAN_SUCCEED) {
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1893 struct page *page, *tmp;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1894
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1895 /*
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1896 * Replacing old pages with new one has succeeded, now we
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1897 * need to copy the content and free the old pages.
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1898 */
2af8ff291848cc Hugh Dickins 2018-11-30 1899 index = start;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1900 list_for_each_entry_safe(page, tmp, &pagelist, lru) {
2af8ff291848cc Hugh Dickins 2018-11-30 1901 while (index < page->index) {
2af8ff291848cc Hugh Dickins 2018-11-30 1902 clear_highpage(new_page + (index % HPAGE_PMD_NR));
2af8ff291848cc Hugh Dickins 2018-11-30 1903 index++;
2af8ff291848cc Hugh Dickins 2018-11-30 1904 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1905 copy_highpage(new_page + (page->index % HPAGE_PMD_NR),
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1906 page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1907 list_del(&page->lru);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1908 page->mapping = NULL;
042a30824871fa Hugh Dickins 2018-11-30 1909 page_ref_unfreeze(page, 1);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1910 ClearPageActive(page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1911 ClearPageUnevictable(page);
042a30824871fa Hugh Dickins 2018-11-30 1912 unlock_page(page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1913 put_page(page);
2af8ff291848cc Hugh Dickins 2018-11-30 1914 index++;
2af8ff291848cc Hugh Dickins 2018-11-30 1915 }
2af8ff291848cc Hugh Dickins 2018-11-30 1916 while (index < end) {
2af8ff291848cc Hugh Dickins 2018-11-30 1917 clear_highpage(new_page + (index % HPAGE_PMD_NR));
2af8ff291848cc Hugh Dickins 2018-11-30 1918 index++;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1919 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1920
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1921 SetPageUptodate(new_page);
87c460a0bded56 Hugh Dickins 2018-11-30 1922 page_ref_add(new_page, HPAGE_PMD_NR - 1);
6058eaec816f29 Johannes Weiner 2020-06-03 1923 if (is_shmem)
99cb0dbd47a15d Song Liu 2019-09-23 1924 set_page_dirty(new_page);
6058eaec816f29 Johannes Weiner 2020-06-03 1925 lru_cache_add(new_page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1926
042a30824871fa Hugh Dickins 2018-11-30 1927 /*
042a30824871fa Hugh Dickins 2018-11-30 1928 * Remove pte page tables, so we can re-fault the page as huge.
042a30824871fa Hugh Dickins 2018-11-30 1929 */
042a30824871fa Hugh Dickins 2018-11-30 1930 retract_page_tables(mapping, start);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1931 *hpage = NULL;
87aa752906ecf6 Yang Shi 2018-08-17 1932
87aa752906ecf6 Yang Shi 2018-08-17 1933 khugepaged_pages_collapsed++;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1934 } else {
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1935 struct page *page;
aaa52e340073b7 Hugh Dickins 2018-11-30 1936
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1937 /* Something went wrong: roll back page cache changes */
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1938 xas_lock_irq(&xas);
aaa52e340073b7 Hugh Dickins 2018-11-30 1939 mapping->nrpages -= nr_none;
99cb0dbd47a15d Song Liu 2019-09-23 1940
99cb0dbd47a15d Song Liu 2019-09-23 1941 if (is_shmem)
aaa52e340073b7 Hugh Dickins 2018-11-30 1942 shmem_uncharge(mapping->host, nr_none);
aaa52e340073b7 Hugh Dickins 2018-11-30 1943
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1944 xas_set(&xas, start);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1945 xas_for_each(&xas, page, end - 1) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1946 page = list_first_entry_or_null(&pagelist,
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1947 struct page, lru);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1948 if (!page || xas.xa_index < page->index) {
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1949 if (!nr_none)
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1950 break;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1951 nr_none--;
59749e6ce53735 Johannes Weiner 2016-12-12 1952 /* Put holes back where they were */
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1953 xas_store(&xas, NULL);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1954 continue;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1955 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1956
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1957 VM_BUG_ON_PAGE(page->index != xas.xa_index, page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1958
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1959 /* Unfreeze the page. */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1960 list_del(&page->lru);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1961 page_ref_unfreeze(page, 2);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1962 xas_store(&xas, page);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1963 xas_pause(&xas);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1964 xas_unlock_irq(&xas);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1965 unlock_page(page);
042a30824871fa Hugh Dickins 2018-11-30 1966 putback_lru_page(page);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1967 xas_lock_irq(&xas);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1968 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1969 VM_BUG_ON(nr_none);
77da9389b9d5f0 Matthew Wilcox 2017-12-04 1970 xas_unlock_irq(&xas);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1971
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1972 new_page->mapping = NULL;
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1973 }
042a30824871fa Hugh Dickins 2018-11-30 1974
042a30824871fa Hugh Dickins 2018-11-30 1975 unlock_page(new_page);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1976 out:
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1977 VM_BUG_ON(!list_empty(&pagelist));
9d82c69438d0df Johannes Weiner 2020-06-03 1978 if (!IS_ERR_OR_NULL(*hpage))
9d82c69438d0df Johannes Weiner 2020-06-03 1979 mem_cgroup_uncharge(*hpage);
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1980 /* TODO: tracepoints */
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1981 }
f3f0e1d2150b2b Kirill A. Shutemov 2016-07-26 1982
:::::: The code at line 1646 was first introduced by commit
:::::: f3f0e1d2150b2b99da2cbdfaad000089efe9bf30 khugepaged: add support of collapse for tmpfs/shmem pages
:::::: TO: Kirill A. Shutemov <kirill.shutemov(a)linux.intel.com>
:::::: CC: Linus Torvalds <torvalds(a)linux-foundation.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[PATCH OLK-5.10] pinmux: Use sequential access to access desc->pinmux data
by Zhang Kunbo 08 Feb '25
by Zhang Kunbo 08 Feb '25
08 Feb '25
From: Mukesh Ojha <quic_mojha(a)quicinc.com>
stable inclusion
from stable-v6.6.66
commit 2da32aed4a97ca1d70fb8b77926f72f30ce5fb4b
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBIFR8
CVE: CVE-2024-47141
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
[ Upstream commit 5a3e85c3c397c781393ea5fb2f45b1f60f8a4e6e ]
When two client of the same gpio call pinctrl_select_state() for the
same functionality, we are seeing NULL pointer issue while accessing
desc->mux_owner.
Let's say two processes A, B executing in pin_request() for the same pin
and process A updates the desc->mux_usecount but not yet updated the
desc->mux_owner while process B see the desc->mux_usecount which got
updated by A path and further executes strcmp and while accessing
desc->mux_owner it crashes with NULL pointer.
Serialize the access to mux related setting with a mutex lock.
cpu0 (process A) cpu1(process B)
pinctrl_select_state() { pinctrl_select_state() {
pin_request() { pin_request() {
...
....
} else {
desc->mux_usecount++;
desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
if (desc->mux_usecount > 1)
return 0;
desc->mux_owner = owner;
} }
Signed-off-by: Mukesh Ojha <quic_mojha(a)quicinc.com>
Link: https://lore.kernel.org/20241014192930.1539673-1-quic_mojha@quicinc.com
Signed-off-by: Linus Walleij <linus.walleij(a)linaro.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Conflicts:
drivers/pinctrl/pinmux.c
[ Scope-based resource management is not merged yet (54da6a092431), so we lock the data-race region by hand ]
Signed-off-by: Zhang Kunbo <zhangkunbo(a)huawei.com>
---
drivers/pinctrl/core.c | 3 +++
drivers/pinctrl/core.h | 1 +
drivers/pinctrl/pinmux.c | 49 ++++++++++++++++++++++++++++++++++------
3 files changed, 46 insertions(+), 7 deletions(-)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index b7a6bab4ac01..118c4975c777 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -220,6 +220,9 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
/* Set owner */
pindesc->pctldev = pctldev;
+#ifdef CONFIG_PINMUX
+ mutex_init(&pindesc->mux_lock);
+#endif
/* Copy basic pin info */
if (pin->name) {
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 840103c40c14..f5e4ca19c17b 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -167,6 +167,7 @@ struct pin_desc {
const char *mux_owner;
const struct pinctrl_setting_mux *mux_setting;
const char *gpio_owner;
+ struct mutex mux_lock;
#endif
};
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index bab888fe3f8e..53fe25e9e864 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -27,6 +27,7 @@
#include <linux/pinctrl/pinmux.h>
#include "core.h"
#include "pinmux.h"
+#include <linux/mutex.h>
int pinmux_check_ops(struct pinctrl_dev *pctldev)
{
@@ -84,15 +85,21 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin)
{
struct pin_desc *desc = pin_desc_get(pctldev, pin);
const struct pinmux_ops *ops = pctldev->desc->pmxops;
+ bool can;
/* Can't inspect pin, assume it can be used */
if (!desc || !ops)
return true;
- if (ops->strict && desc->mux_usecount)
+ mutex_lock(&desc->mux_lock);
+ if (ops->strict && desc->mux_usecount) {
+ mutex_unlock(&desc->mux_lock);
return false;
+ }
- return !(ops->strict && !!desc->gpio_owner);
+ can = !(ops->strict && !!desc->gpio_owner);
+ mutex_unlock(&desc->mux_lock);
+ return can;
}
/**
@@ -123,11 +130,13 @@ static int pin_request(struct pinctrl_dev *pctldev,
dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
pin, desc->name, owner);
+ mutex_lock(&desc->mux_lock);
if ((!gpio_range || ops->strict) &&
desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->mux_owner, owner);
+ mutex_unlock(&desc->mux_lock);
goto out;
}
@@ -135,6 +144,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->gpio_owner, owner);
+ mutex_unlock(&desc->mux_lock);
goto out;
}
@@ -142,11 +152,14 @@ static int pin_request(struct pinctrl_dev *pctldev,
desc->gpio_owner = owner;
} else {
desc->mux_usecount++;
- if (desc->mux_usecount > 1)
+ if (desc->mux_usecount > 1) {
+ mutex_unlock(&desc->mux_lock);
return 0;
+ }
desc->mux_owner = owner;
}
+ mutex_unlock(&desc->mux_lock);
/* Let each pin increase references to this module */
if (!try_module_get(pctldev->owner)) {
@@ -176,6 +189,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
out_free_pin:
if (status) {
+ mutex_lock(&desc->mux_lock);
if (gpio_range) {
desc->gpio_owner = NULL;
} else {
@@ -183,6 +197,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
if (!desc->mux_usecount)
desc->mux_owner = NULL;
}
+ mutex_unlock(&desc->mux_lock);
}
out:
if (status)
@@ -217,16 +232,22 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
return NULL;
}
+ mutex_lock(&desc->mux_lock);
if (!gpio_range) {
/*
* A pin should not be freed more times than allocated.
*/
- if (WARN_ON(!desc->mux_usecount))
+ if (WARN_ON(!desc->mux_usecount)) {
+ mutex_unlock(&desc->mux_lock);
return NULL;
+ }
desc->mux_usecount--;
- if (desc->mux_usecount)
+ if (desc->mux_usecount) {
+ mutex_unlock(&desc->mux_lock);
return NULL;
+ }
}
+ mutex_unlock(&desc->mux_lock);
/*
* If there is no kind of request function for the pin we just assume
@@ -237,6 +258,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
else if (ops->free)
ops->free(pctldev, pin);
+ mutex_lock(&desc->mux_lock);
if (gpio_range) {
owner = desc->gpio_owner;
desc->gpio_owner = NULL;
@@ -245,6 +267,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
desc->mux_owner = NULL;
desc->mux_setting = NULL;
}
+ mutex_unlock(&desc->mux_lock);
module_put(pctldev->owner);
@@ -457,7 +480,9 @@ int pinmux_enable_setting(const struct pinctrl_setting *setting)
pins[i]);
continue;
}
+ mutex_lock(&desc->mux_lock);
desc->mux_setting = &(setting->data.mux);
+ mutex_unlock(&desc->mux_lock);
}
ret = ops->set_mux(pctldev, setting->data.mux.func,
@@ -471,8 +496,11 @@ int pinmux_enable_setting(const struct pinctrl_setting *setting)
err_set_mux:
for (i = 0; i < num_pins; i++) {
desc = pin_desc_get(pctldev, pins[i]);
- if (desc)
+ if (desc) {
+ mutex_lock(&desc->mux_lock);
desc->mux_setting = NULL;
+ mutex_unlock(&desc->mux_lock);
+ }
}
err_pin_request:
/* On error release all taken pins */
@@ -491,6 +519,7 @@ void pinmux_disable_setting(const struct pinctrl_setting *setting)
unsigned num_pins = 0;
int i;
struct pin_desc *desc;
+ bool is_equal;
if (pctlops->get_group_pins)
ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
@@ -516,7 +545,11 @@ void pinmux_disable_setting(const struct pinctrl_setting *setting)
pins[i]);
continue;
}
- if (desc->mux_setting == &(setting->data.mux)) {
+ mutex_lock(&desc->mux_lock);
+ is_equal = (desc->mux_setting == &(setting->data.mux));
+ mutex_unlock(&desc->mux_lock);
+
+ if (is_equal) {
pin_free(pctldev, pins[i], NULL);
} else {
const char *gname;
@@ -608,6 +641,7 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
if (desc == NULL)
continue;
+ mutex_lock(&desc->mux_lock);
if (desc->mux_owner &&
!strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev)))
is_hog = true;
@@ -642,6 +676,7 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
desc->mux_setting->group));
else
seq_putc(s, '\n');
+ mutex_unlock(&desc->mux_lock);
}
mutex_unlock(&pctldev->mutex);
--
2.34.1
2
1

[openeuler:openEuler-1.0-LTS] BUILD REGRESSION 3e25b4f1b2a403f9c9bbcabb005b882397477053
by kernel test robot 08 Feb '25
by kernel test robot 08 Feb '25
08 Feb '25
tree/branch: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
branch HEAD: 3e25b4f1b2a403f9c9bbcabb005b882397477053 !15042 drm: adv7511: Fix use-after-free in adv7533_attach_dsi()
Error/Warning (recently discovered and may have been fixed):
https://lore.kernel.org/oe-kbuild-all/202502072305.gE5j9Qd8-lkp@intel.com
mm/ioremap.o: warning: objtool: missing symbol for section .text
Error/Warning ids grouped by kconfigs:
recent_errors
|-- arm64-allmodconfig
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-__bio_integrity_free
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-blkg-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-delta-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-now-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-q-not-described-in-blkcg_schedule_throttle
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-use_memdelay-not-described-in-blkcg_schedule_throttle
| |-- block-blk-io-hierarchy-iodump.c:warning:no-previous-prototype-for-__bio_stage_hierarchy_start
| |-- block-blk-iolatency.c:warning:variable-blkiolat-set-but-not-used
| |-- block-blk-iolatency.c:warning:variable-changed-set-but-not-used
| |-- block-blk-merge.c:warning:no-previous-prototype-for-blk_try_req_merge
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-__blk_mq_sched_dispatch_requests
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-wbt_issue
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-wbt_requeue
| |-- block-genhd.c:warning:no-previous-prototype-for-disk_scan_partitions
| |-- drivers-net-ethernet-netswift-ngbe-ngbe_main.c:warning:unused-variable-len
| |-- include-asm-generic-bitops-non-atomic.h:warning:array-subscript-long-unsigned-int-is-partly-outside-array-bounds-of-u32-aka-unsigned-int
| |-- include-linux-kernel.h:warning:comparison-of-distinct-pointer-types-lacks-a-cast
| |-- include-linux-thread_info.h:warning:b-may-be-used-uninitialized
| |-- include-net-netns-generic.h:warning:array-subscript-id-is-outside-array-bounds-of-void
| `-- include-scsi-scsi_cmnd.h:warning:scsi_cmnd-may-be-used-uninitialized
|-- arm64-allnoconfig
| |-- include-linux-mempolicy.h:warning:__do_mbind-defined-but-not-used
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-CRYPTO_AES-when-selected-by-RTLLIB_CRYPTO_CCMP
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-CRYPTO_ARC4-when-selected-by-RTLLIB_CRYPTO_TKIP
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-CRYPTO_ARC4-when-selected-by-RTLLIB_CRYPTO_WEP
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-CRYPTO_MICHAEL_MIC-when-selected-by-RTLLIB_CRYPTO_TKIP
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-FB_BACKLIGHT-when-selected-by-DRM_NOUVEAU
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-HARDLOCKUP_DETECTOR-when-selected-by-SDEI_WATCHDOG
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-IIO_BUFFER_CB-when-selected-by-TOUCHSCREEN_ADC
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-PINCTRL_EXYNOS-when-selected-by-ARCH_EXYNOS
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-SPI_PHYTIUM-when-selected-by-SPI_PHYTIUM_PCI
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-SPI_PHYTIUM-when-selected-by-SPI_PHYTIUM_PLAT
| |-- kismet:WARNING:unmet-direct-dependencies-detected-for-UACCE-when-selected-by-CRYPTO_DEV_HISI_QM
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled
|-- arm64-randconfig-001-20250207
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-__bio_integrity_free
| |-- block-blk-merge.c:warning:no-previous-prototype-for-blk_try_req_merge
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-__blk_mq_sched_dispatch_requests
| |-- block-genhd.c:warning:no-previous-prototype-for-disk_scan_partitions
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| |-- include-linux-filter.h:warning:cast-between-incompatible-function-types-from-u64-(-)(u64-u64-u64-u64-u64)-aka-long-long-unsigned-int-(-)(long-long-unsigned-int-long-long-unsigned-int-long-long-unsigne
| |-- include-linux-list.h:warning:array-subscript-is-outside-array-bounds-of-struct-plist_node
| |-- include-linux-list.h:warning:storing-the-address-of-local-variable-tmp-in-((struct-list_head-)lip)-.prev
| |-- include-linux-mempolicy.h:warning:__do_mbind-defined-but-not-used
| `-- include-linux-plist.h:warning:array-subscript-is-outside-array-bounds-of-struct-plist_node
|-- arm64-randconfig-002-20250207
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-__bio_integrity_free
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-blkg-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-delta-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-now-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-q-not-described-in-blkcg_schedule_throttle
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-use_memdelay-not-described-in-blkcg_schedule_throttle
| |-- block-blk-iolatency.c:warning:variable-blkiolat-set-but-not-used
| |-- block-blk-iolatency.c:warning:variable-changed-set-but-not-used
| |-- block-blk-merge.c:warning:no-previous-prototype-for-blk_try_req_merge
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-__blk_mq_sched_dispatch_requests
| |-- block-genhd.c:warning:no-previous-prototype-for-disk_scan_partitions
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| |-- include-linux-filter.h:warning:cast-between-incompatible-function-types-from-u64-(-)(u64-u64-u64-u64-u64)-aka-long-long-unsigned-int-(-)(long-long-unsigned-int-long-long-unsigned-int-long-long-unsigne
| |-- include-linux-kernel.h:warning:comparison-of-distinct-pointer-types-lacks-a-cast
| |-- include-linux-mempolicy.h:warning:__do_mbind-defined-but-not-used
| |-- include-net-netns-generic.h:warning:array-subscript-id-is-outside-array-bounds-of-void
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled
|-- arm64-randconfig-003-20250207
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-__bio_integrity_free
| |-- block-blk-merge.c:warning:no-previous-prototype-for-blk_try_req_merge
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-__blk_mq_sched_dispatch_requests
| |-- block-genhd.c:warning:no-previous-prototype-for-disk_scan_partitions
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| |-- include-linux-filter.h:warning:cast-between-incompatible-function-types-from-u64-(-)(u64-u64-u64-u64-u64)-aka-long-long-unsigned-int-(-)(long-long-unsigned-int-long-long-unsigned-int-long-long-unsigne
| |-- include-linux-mempolicy.h:warning:__do_mbind-defined-but-not-used
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled
|-- arm64-randconfig-004-20250207
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| |-- include-linux-filter.h:warning:cast-between-incompatible-function-types-from-u64-(-)(u64-u64-u64-u64-u64)-aka-long-long-unsigned-int-(-)(long-long-unsigned-int-long-long-unsigned-int-long-long-unsigne
| |-- include-linux-mempolicy.h:warning:__do_mbind-defined-but-not-used
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled
|-- x86_64-allmodconfig
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-blkg-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-delta-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-now-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-q-not-described-in-blkcg_schedule_throttle
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-use_memdelay-not-described-in-blkcg_schedule_throttle
| |-- block-blk-iolatency.c:warning:variable-blkiolat-set-but-not-used
| |-- block-blk-iolatency.c:warning:variable-changed-set-but-not-used
| `-- block-blk-mq-sched.c:warning:no-previous-prototype-for-function-__blk_mq_sched_dispatch_requests
|-- x86_64-allnoconfig
| |-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled-Werror-Wimplicit-function-declaration
|-- x86_64-allyesconfig
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-function-__bio_integrity_free
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-blkg-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-delta-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-now-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-q-not-described-in-blkcg_schedule_throttle
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-use_memdelay-not-described-in-blkcg_schedule_throttle
| |-- block-blk-iolatency.c:warning:variable-blkiolat-set-but-not-used
| |-- block-blk-iolatency.c:warning:variable-changed-set-but-not-used
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-function-__blk_mq_sched_dispatch_requests
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-function-wbt_issue
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-function-wbt_requeue
| |-- block-genhd.c:warning:no-previous-prototype-for-function-disk_scan_partitions
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-net-ethernet-netswift-ngbe-ngbe_main.c:warning:unused-variable-len
| `-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
|-- x86_64-buildonly-randconfig-001-20250207
| |-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
| |-- arch-x86-entry-entry_64.o:warning:objtool:If-this-is-a-retpoline-please-patch-it-in-with-alternatives-and-annotate-it-with-ANNOTATE_NOSPEC_ALTERNATIVE.
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| |-- include-linux-mempolicy.h:warning:__do_mbind-defined-but-not-used
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled
|-- x86_64-buildonly-randconfig-002-20250207
| |-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
| |-- arch-x86-entry-entry_64.o:warning:objtool:If-this-is-a-retpoline-please-patch-it-in-with-alternatives-and-annotate-it-with-ANNOTATE_NOSPEC_ALTERNATIVE.
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-function-__bio_integrity_free
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-blkg-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-delta-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-now-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-q-not-described-in-blkcg_schedule_throttle
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-use_memdelay-not-described-in-blkcg_schedule_throttle
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-function-__blk_mq_sched_dispatch_requests
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-function-wbt_issue
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-function-wbt_requeue
| |-- block-genhd.c:warning:no-previous-prototype-for-function-disk_scan_partitions
| `-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
|-- x86_64-buildonly-randconfig-003-20250207
| |-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
| |-- arch-x86-entry-entry_64.o:warning:objtool:If-this-is-a-retpoline-please-patch-it-in-with-alternatives-and-annotate-it-with-ANNOTATE_NOSPEC_ALTERNATIVE.
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled-Werror-Wimplicit-function-declaration
|-- x86_64-buildonly-randconfig-004-20250207
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-function-__bio_integrity_free
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-blkg-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-delta-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-now-not-described-in-blkcg_add_delay
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-q-not-described-in-blkcg_schedule_throttle
| |-- block-blk-cgroup.c:warning:Function-parameter-or-member-use_memdelay-not-described-in-blkcg_schedule_throttle
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-function-__blk_mq_sched_dispatch_requests
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-function-wbt_issue
| |-- block-blk-wbt.c:warning:no-previous-prototype-for-function-wbt_requeue
| |-- block-genhd.c:warning:no-previous-prototype-for-function-disk_scan_partitions
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| `-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
|-- x86_64-buildonly-randconfig-005-20250207
| |-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
| |-- arch-x86-entry-entry_64.o:warning:objtool:If-this-is-a-retpoline-please-patch-it-in-with-alternatives-and-annotate-it-with-ANNOTATE_NOSPEC_ALTERNATIVE.
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| |-- mm-ioremap.o:warning:objtool:missing-symbol-for-section-.text
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled-Werror-Wimplicit-function-declaration
|-- x86_64-buildonly-randconfig-006-20250207
| |-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
| |-- arch-x86-entry-entry_64.o:warning:objtool:If-this-is-a-retpoline-please-patch-it-in-with-alternatives-and-annotate-it-with-ANNOTATE_NOSPEC_ALTERNATIVE.
| |-- block-bio-integrity.c:warning:no-previous-prototype-for-function-__bio_integrity_free
| |-- block-blk-mq-sched.c:warning:no-previous-prototype-for-function-__blk_mq_sched_dispatch_requests
| |-- block-genhd.c:warning:no-previous-prototype-for-function-disk_scan_partitions
| |-- drivers-gpu-drm-ttm-ttm_object.c:error:Cannot-parse-struct-or-union
| |-- drivers-pinctrl-core.c:error:Cannot-parse-struct-or-union
| `-- mm-vmscan.c:error:implicit-declaration-of-function-kernel_swap_enabled-Werror-Wimplicit-function-declaration
`-- x86_64-defconfig
|-- arch-x86-entry-entry_64.o:warning:objtool:.entry.text:unsupported-intra-function-call
|-- arch-x86-entry-entry_64.o:warning:objtool:If-this-is-a-retpoline-please-patch-it-in-with-alternatives-and-annotate-it-with-ANNOTATE_NOSPEC_ALTERNATIVE.
|-- block-blk-merge.c:warning:no-previous-prototype-for-blk_try_req_merge
|-- block-blk-mq-sched.c:warning:no-previous-prototype-for-__blk_mq_sched_dispatch_requests
|-- block-genhd.c:warning:no-previous-prototype-for-disk_scan_partitions
|-- include-linux-filter.h:warning:cast-between-incompatible-function-types-from-u64-(-)(u64-u64-u64-u64-u64)-aka-long-long-unsigned-int-(-)(long-long-unsigned-int-long-long-unsigned-int-long-long-unsigne
`-- include-linux-kernel.h:warning:comparison-of-distinct-pointer-types-lacks-a-cast
elapsed time: 779m
configs tested: 15
configs skipped: 112
tested configs:
arm64 allmodconfig gcc-14.2.0
arm64 allnoconfig gcc-14.2.0
arm64 randconfig-001-20250207 gcc-14.2.0
arm64 randconfig-002-20250207 gcc-14.2.0
arm64 randconfig-003-20250207 gcc-14.2.0
arm64 randconfig-004-20250207 gcc-14.2.0
x86_64 allnoconfig clang-19
x86_64 allyesconfig clang-19
x86_64 buildonly-randconfig-001-20250207 gcc-12
x86_64 buildonly-randconfig-002-20250207 clang-19
x86_64 buildonly-randconfig-003-20250207 clang-19
x86_64 buildonly-randconfig-004-20250207 clang-19
x86_64 buildonly-randconfig-005-20250207 clang-19
x86_64 buildonly-randconfig-006-20250207 clang-19
x86_64 defconfig gcc-11
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[openeuler:OLK-6.6 1901/1901] drivers/net/ethernet/huawei/hinic/hinic_main.c:204:30: error: member reference type 'int' is not a pointer
by kernel test robot 08 Feb '25
by kernel test robot 08 Feb '25
08 Feb '25
Hi Zhou,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git OLK-6.6
head: be69fb5fc3212547e4408752b099094739f31aaa
commit: 9c1c9598010fbb9daa1e2a67d23830092fb6246a [1901/1901] net/hinic: Update Huawei Intelligent Network Card Driver: hinic
config: x86_64-buildonly-randconfig-001-20250208 (https://download.01.org/0day-ci/archive/20250208/202502080513.W05LfnyB-lkp@…)
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/20250208/202502080513.W05LfnyB-lkp@…)
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(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502080513.W05LfnyB-lkp@intel.com/
All errors (new ones prefixed by >>):
In file included from drivers/net/ethernet/huawei/hinic/hinic_main.c:18:
In file included from include/linux/pci.h:1663:
In file included from include/linux/dmapool.h:14:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2193:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
drivers/net/ethernet/huawei/hinic/hinic_main.c:204:9: error: call to undeclared function 'vlan_dev_priv'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
204 | ret = vlan_dev_priv(ndev)->real_dev;
| ^
>> drivers/net/ethernet/huawei/hinic/hinic_main.c:204:30: error: member reference type 'int' is not a pointer
204 | ret = vlan_dev_priv(ndev)->real_dev;
| ~~~~~~~~~~~~~~~~~~~ ^
drivers/net/ethernet/huawei/hinic/hinic_main.c:206:30: error: member reference type 'int' is not a pointer
206 | ret = vlan_dev_priv(ret)->real_dev;
| ~~~~~~~~~~~~~~~~~~ ^
drivers/net/ethernet/huawei/hinic/hinic_main.c:182:5: warning: no previous prototype for function 'hinic_netdev_event' [-Wmissing-prototypes]
182 | int hinic_netdev_event(struct notifier_block *notifier,
| ^
drivers/net/ethernet/huawei/hinic/hinic_main.c:182:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
182 | int hinic_netdev_event(struct notifier_block *notifier,
| ^
| static
drivers/net/ethernet/huawei/hinic/hinic_main.c:2291:21: error: no member named 'dcbnl_ops' in 'struct net_device'
2291 | adapter->netdev->dcbnl_ops = &hinic_dcbnl_ops;
| ~~~~~~~~~~~~~~~ ^
drivers/net/ethernet/huawei/hinic/hinic_main.c:3058:6: warning: no previous prototype for function 'nic_event' [-Wmissing-prototypes]
3058 | void nic_event(struct hinic_lld_dev *lld_dev, void *adapter,
| ^
drivers/net/ethernet/huawei/hinic/hinic_main.c:3058:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
3058 | void nic_event(struct hinic_lld_dev *lld_dev, void *adapter,
| ^
| static
3 warnings and 4 errors generated.
vim +/int +204 drivers/net/ethernet/huawei/hinic/hinic_main.c
176
177 #define HINIC_MAX_VLAN_DEPTH_OFFLOAD_SUPPORT 2
178 #define HINIC_VLAN_CLEAR_OFFLOAD (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | \
179 NETIF_F_SCTP_CRC | NETIF_F_RXCSUM | \
180 NETIF_F_ALL_TSO)
181
182 int hinic_netdev_event(struct notifier_block *notifier,
183 unsigned long event, void *ptr)
184 {
185 struct net_device *ndev = netdev_notifier_info_to_dev(ptr);
186 struct net_device *real_dev, *ret;
187 struct hinic_nic_dev *nic_dev;
188 u16 vlan_depth;
189
190 if (!is_vlan_dev(ndev))
191 return NOTIFY_DONE;
192
193 dev_hold(ndev);
194
195 switch (event) {
196 case NETDEV_REGISTER:
197 real_dev = vlan_dev_real_dev(ndev);
198 nic_dev = hinic_get_uld_dev_by_ifname(real_dev->name,
199 SERVICE_T_NIC);
200 if (!nic_dev)
201 goto out;
202
203 vlan_depth = 1;
> 204 ret = vlan_dev_priv(ndev)->real_dev;
205 while (is_vlan_dev(ret)) {
206 ret = vlan_dev_priv(ret)->real_dev;
207 vlan_depth++;
208 }
209
210 if (vlan_depth == HINIC_MAX_VLAN_DEPTH_OFFLOAD_SUPPORT) {
211 ndev->vlan_features &= (~HINIC_VLAN_CLEAR_OFFLOAD);
212 } else if (vlan_depth > HINIC_MAX_VLAN_DEPTH_OFFLOAD_SUPPORT) {
213 ndev->hw_features &= (~HINIC_VLAN_CLEAR_OFFLOAD);
214 ndev->features &= (~HINIC_VLAN_CLEAR_OFFLOAD);
215 }
216
217 break;
218
219 default:
220 break;
221 };
222
223 out:
224 dev_put(ndev);
225
226 return NOTIFY_DONE;
227 }
228
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[openeuler:openEuler-1.0-LTS 1418/1418] mm/ioremap.o: warning: objtool: missing symbol for section .text
by kernel test robot 07 Feb '25
by kernel test robot 07 Feb '25
07 Feb '25
Hi Nicholas,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 3e25b4f1b2a403f9c9bbcabb005b882397477053
commit: 004cface9c1c0b6351473934a4ce452193e05b07 [1418/1418] mm: Move vmap_range from mm/ioremap.c to mm/vmalloc.c
config: x86_64-buildonly-randconfig-005-20250207 (https://download.01.org/0day-ci/archive/20250207/202502072305.gE5j9Qd8-lkp@…)
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/20250207/202502072305.gE5j9Qd8-lkp@…)
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(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502072305.gE5j9Qd8-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> mm/ioremap.o: warning: objtool: missing symbol for section .text
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[PATCH OLK-5.10] pinmux: Use sequential access to access desc->pinmux data
by Zhang Kunbo 07 Feb '25
by Zhang Kunbo 07 Feb '25
07 Feb '25
From: Mukesh Ojha <quic_mojha(a)quicinc.com>
stable inclusion
from stable-v6.6.66
commit 2da32aed4a97ca1d70fb8b77926f72f30ce5fb4b
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBIFR8
CVE: CVE-2024-47141
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
[ Upstream commit 5a3e85c3c397c781393ea5fb2f45b1f60f8a4e6e ]
When two client of the same gpio call pinctrl_select_state() for the
same functionality, we are seeing NULL pointer issue while accessing
desc->mux_owner.
Let's say two processes A, B executing in pin_request() for the same pin
and process A updates the desc->mux_usecount but not yet updated the
desc->mux_owner while process B see the desc->mux_usecount which got
updated by A path and further executes strcmp and while accessing
desc->mux_owner it crashes with NULL pointer.
Serialize the access to mux related setting with a mutex lock.
cpu0 (process A) cpu1(process B)
pinctrl_select_state() { pinctrl_select_state() {
pin_request() { pin_request() {
...
....
} else {
desc->mux_usecount++;
desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
if (desc->mux_usecount > 1)
return 0;
desc->mux_owner = owner;
} }
Signed-off-by: Mukesh Ojha <quic_mojha(a)quicinc.com>
Link: https://lore.kernel.org/20241014192930.1539673-1-quic_mojha@quicinc.com
Signed-off-by: Linus Walleij <linus.walleij(a)linaro.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Conflicts:
drivers/pinctrl/pinmux.c
[ Scope-based resource management is not merged yet (54da6a092431), so we lock the data-race region by hand ]
Signed-off-by: Zhang Kunbo <zhangkunbo(a)huawei.com>
---
drivers/pinctrl/core.c | 3 +++
drivers/pinctrl/core.h | 1 +
drivers/pinctrl/pinmux.c | 39 ++++++++++++++++++++++++++++++++++-----
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index b7a6bab4ac01..118c4975c777 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -220,6 +220,9 @@ static int pinctrl_register_one_pin(struct pinctrl_dev *pctldev,
/* Set owner */
pindesc->pctldev = pctldev;
+#ifdef CONFIG_PINMUX
+ mutex_init(&pindesc->mux_lock);
+#endif
/* Copy basic pin info */
if (pin->name) {
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 840103c40c14..f5e4ca19c17b 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -167,6 +167,7 @@ struct pin_desc {
const char *mux_owner;
const struct pinctrl_setting_mux *mux_setting;
const char *gpio_owner;
+ struct mutex mux_lock;
#endif
};
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index bab888fe3f8e..9d38ef1a77be 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -27,6 +27,7 @@
#include <linux/pinctrl/pinmux.h>
#include "core.h"
#include "pinmux.h"
+#include <linux/mutex.h>
int pinmux_check_ops(struct pinctrl_dev *pctldev)
{
@@ -84,15 +85,21 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin)
{
struct pin_desc *desc = pin_desc_get(pctldev, pin);
const struct pinmux_ops *ops = pctldev->desc->pmxops;
+ bool can;
/* Can't inspect pin, assume it can be used */
if (!desc || !ops)
return true;
- if (ops->strict && desc->mux_usecount)
+ mutex_lock(&desc->mux_lock);
+ if (ops->strict && desc->mux_usecount) {
+ mutex_unlock(&desc->mux_lock);
return false;
+ }
- return !(ops->strict && !!desc->gpio_owner);
+ can = !(ops->strict && !!desc->gpio_owner);
+ mutex_unlock(&desc->mux_lock);
+ return can;
}
/**
@@ -123,11 +130,13 @@ static int pin_request(struct pinctrl_dev *pctldev,
dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n",
pin, desc->name, owner);
+ mutex_lock(&desc->mux_lock);
if ((!gpio_range || ops->strict) &&
desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->mux_owner, owner);
+ mutex_unlock(&desc->mux_lock);
goto out;
}
@@ -135,6 +144,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
dev_err(pctldev->dev,
"pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->gpio_owner, owner);
+ mutex_unlock(&desc->mux_lock);
goto out;
}
@@ -142,11 +152,14 @@ static int pin_request(struct pinctrl_dev *pctldev,
desc->gpio_owner = owner;
} else {
desc->mux_usecount++;
- if (desc->mux_usecount > 1)
+ if (desc->mux_usecount > 1) {
+ mutex_unlock(&desc->mux_lock);
return 0;
+ }
desc->mux_owner = owner;
}
+ mutex_unlock(&desc->mux_lock);
/* Let each pin increase references to this module */
if (!try_module_get(pctldev->owner)) {
@@ -176,6 +189,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
out_free_pin:
if (status) {
+ mutex_lock(&desc->mux_lock);
if (gpio_range) {
desc->gpio_owner = NULL;
} else {
@@ -183,6 +197,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
if (!desc->mux_usecount)
desc->mux_owner = NULL;
}
+ mutex_unlock(&desc->mux_lock);
}
out:
if (status)
@@ -237,6 +252,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
else if (ops->free)
ops->free(pctldev, pin);
+ mutex_lock(&desc->mux_lock);
if (gpio_range) {
owner = desc->gpio_owner;
desc->gpio_owner = NULL;
@@ -245,6 +261,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
desc->mux_owner = NULL;
desc->mux_setting = NULL;
}
+ mutex_unlock(&desc->mux_lock);
module_put(pctldev->owner);
@@ -457,7 +474,9 @@ int pinmux_enable_setting(const struct pinctrl_setting *setting)
pins[i]);
continue;
}
+ mutex_lock(&desc->mux_lock);
desc->mux_setting = &(setting->data.mux);
+ mutex_unlock(&desc->mux_lock);
}
ret = ops->set_mux(pctldev, setting->data.mux.func,
@@ -471,8 +490,11 @@ int pinmux_enable_setting(const struct pinctrl_setting *setting)
err_set_mux:
for (i = 0; i < num_pins; i++) {
desc = pin_desc_get(pctldev, pins[i]);
- if (desc)
+ if (desc) {
+ mutex_lock(&desc->mux_lock);
desc->mux_setting = NULL;
+ mutex_unlock(&desc->mux_lock);
+ }
}
err_pin_request:
/* On error release all taken pins */
@@ -491,6 +513,7 @@ void pinmux_disable_setting(const struct pinctrl_setting *setting)
unsigned num_pins = 0;
int i;
struct pin_desc *desc;
+ bool is_equal;
if (pctlops->get_group_pins)
ret = pctlops->get_group_pins(pctldev, setting->data.mux.group,
@@ -516,7 +539,11 @@ void pinmux_disable_setting(const struct pinctrl_setting *setting)
pins[i]);
continue;
}
- if (desc->mux_setting == &(setting->data.mux)) {
+ mutex_lock(&desc->mux_lock);
+ is_equal = (desc->mux_setting == &(setting->data.mux));
+ mutex_unlock(&desc->mux_lock);
+
+ if (is_equal) {
pin_free(pctldev, pins[i], NULL);
} else {
const char *gname;
@@ -608,6 +635,7 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
if (desc == NULL)
continue;
+ mutex_lock(&desc->mux_lock);
if (desc->mux_owner &&
!strcmp(desc->mux_owner, pinctrl_dev_get_name(pctldev)))
is_hog = true;
@@ -642,6 +670,7 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
desc->mux_setting->group));
else
seq_putc(s, '\n');
+ mutex_unlock(&desc->mux_lock);
}
mutex_unlock(&pctldev->mutex);
--
2.34.1
2
1

[openeuler:OLK-6.6 1897/1897] mm/memblock.c:1409:20: warning: no previous prototype for 'memblock_alloc_range_nid_flags'
by kernel test robot 07 Feb '25
by kernel test robot 07 Feb '25
07 Feb '25
Hi Ma,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git OLK-6.6
head: fdc8c83a12a8fc4b7c55971d552758ffe2f34c14
commit: 64018b291c1f49622c4b23b303364d760306d662 [1897/1897] mm/memblock: Introduce ability to alloc memory from specify memory region
config: x86_64-alldefconfig (https://download.01.org/0day-ci/archive/20250207/202502071449.bIBBpkJp-lkp@…)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250207/202502071449.bIBBpkJp-lkp@…)
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(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502071449.bIBBpkJp-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> mm/memblock.c:1409:20: warning: no previous prototype for 'memblock_alloc_range_nid_flags' [-Wmissing-prototypes]
1409 | phys_addr_t __init memblock_alloc_range_nid_flags(phys_addr_t size,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
>> mm/memblock.c:1579: warning: expecting prototype for memblock_alloc_internal(). Prototype was for __memblock_alloc_internal() instead
vim +/memblock_alloc_range_nid_flags +1409 mm/memblock.c
1386
1387 /**
1388 * memblock_alloc_range_nid_flags - allocate boot memory block with specify flag
1389 * @size: size of memory block to be allocated in bytes
1390 * @align: alignment of the region and block's size
1391 * @start: the lower bound of the memory region to allocate (phys address)
1392 * @end: the upper bound of the memory region to allocate (phys address)
1393 * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1394 * @exact_nid: control the allocation fall back to other nodes
1395 * @flags: alloc memory from specify memblock flag
1396 *
1397 * The allocation is performed from memory region limited by
1398 * memblock.current_limit if @end == %MEMBLOCK_ALLOC_ACCESSIBLE.
1399 *
1400 * If the specified node can not hold the requested memory and @exact_nid
1401 * is false, the allocation falls back to any node in the system.
1402 *
1403 * In addition, function sets the min_count to 0 using kmemleak_alloc_phys for
1404 * allocated boot memory block, so that it is never reported as leaks.
1405 *
1406 * Return:
1407 * Physical address of allocated memory block on success, %0 on failure.
1408 */
> 1409 phys_addr_t __init memblock_alloc_range_nid_flags(phys_addr_t size,
1410 phys_addr_t align, phys_addr_t start,
1411 phys_addr_t end, int nid,
1412 bool exact_nid,
1413 enum memblock_flags flags)
1414 {
1415 phys_addr_t found;
1416
1417 if (WARN_ONCE(nid == MAX_NUMNODES, "Usage of MAX_NUMNODES is deprecated. Use NUMA_NO_NODE instead\n"))
1418 nid = NUMA_NO_NODE;
1419
1420 if (!align) {
1421 /* Can't use WARNs this early in boot on powerpc */
1422 dump_stack();
1423 align = SMP_CACHE_BYTES;
1424 }
1425
1426 again:
1427 found = memblock_find_in_range_node(size, align, start, end, nid,
1428 flags);
1429 if (found && !memblock_reserve(found, size))
1430 goto done;
1431
1432 if (nid != NUMA_NO_NODE && !exact_nid) {
1433 found = memblock_find_in_range_node(size, align, start,
1434 end, NUMA_NO_NODE,
1435 flags);
1436 if (found && !memblock_reserve(found, size))
1437 goto done;
1438 }
1439
1440 if (flags & MEMBLOCK_MIRROR) {
1441 flags &= ~MEMBLOCK_MIRROR;
1442 pr_warn_ratelimited("Could not allocate %pap bytes of mirrored memory\n",
1443 &size);
1444 goto again;
1445 }
1446
1447 return 0;
1448
1449 done:
1450 /*
1451 * Skip kmemleak for those places like kasan_init() and
1452 * early_pgtable_alloc() due to high volume.
1453 */
1454 if (end != MEMBLOCK_ALLOC_NOLEAKTRACE)
1455 /*
1456 * Memblock allocated blocks are never reported as
1457 * leaks. This is because many of these blocks are
1458 * only referred via the physical address which is
1459 * not looked up by kmemleak.
1460 */
1461 kmemleak_alloc_phys(found, size, 0);
1462
1463 /*
1464 * Some Virtual Machine platforms, such as Intel TDX or AMD SEV-SNP,
1465 * require memory to be accepted before it can be used by the
1466 * guest.
1467 *
1468 * Accept the memory of the allocated buffer.
1469 */
1470 accept_memory(found, found + size);
1471
1472 return found;
1473 }
1474
1475 /**
1476 * memblock_alloc_range_nid - allocate boot memory block
1477 * @size: size of memory block to be allocated in bytes
1478 * @align: alignment of the region and block's size
1479 * @start: the lower bound of the memory region to allocate (phys address)
1480 * @end: the upper bound of the memory region to allocate (phys address)
1481 * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1482 * @exact_nid: control the allocation fall back to other nodes
1483 *
1484 * The allocation is performed from memory region limited by
1485 * memblock.current_limit if @end == %MEMBLOCK_ALLOC_ACCESSIBLE.
1486 *
1487 * If the specified node can not hold the requested memory and @exact_nid
1488 * is false, the allocation falls back to any node in the system.
1489 *
1490 * For systems with memory mirroring, the allocation is attempted first
1491 * from the regions with mirroring enabled and then retried from any
1492 * memory region.
1493 *
1494 * In addition, function using kmemleak_alloc_phys for allocated boot
1495 * memory block, it is never reported as leaks.
1496 *
1497 * Return:
1498 * Physical address of allocated memory block on success, %0 on failure.
1499 */
1500 phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size,
1501 phys_addr_t align, phys_addr_t start,
1502 phys_addr_t end, int nid,
1503 bool exact_nid)
1504 {
1505 return memblock_alloc_range_nid_flags(size, align, start, end, nid,
1506 exact_nid,
1507 choose_memblock_flags());
1508 }
1509
1510 /**
1511 * memblock_phys_alloc_range - allocate a memory block inside specified range
1512 * @size: size of memory block to be allocated in bytes
1513 * @align: alignment of the region and block's size
1514 * @start: the lower bound of the memory region to allocate (physical address)
1515 * @end: the upper bound of the memory region to allocate (physical address)
1516 *
1517 * Allocate @size bytes in the between @start and @end.
1518 *
1519 * Return: physical address of the allocated memory block on success,
1520 * %0 on failure.
1521 */
1522 phys_addr_t __init memblock_phys_alloc_range(phys_addr_t size,
1523 phys_addr_t align,
1524 phys_addr_t start,
1525 phys_addr_t end)
1526 {
1527 memblock_dbg("%s: %llu bytes align=0x%llx from=%pa max_addr=%pa %pS\n",
1528 __func__, (u64)size, (u64)align, &start, &end,
1529 (void *)_RET_IP_);
1530 return memblock_alloc_range_nid(size, align, start, end, NUMA_NO_NODE,
1531 false);
1532 }
1533
1534 /**
1535 * memblock_phys_alloc_try_nid - allocate a memory block from specified NUMA node
1536 * @size: size of memory block to be allocated in bytes
1537 * @align: alignment of the region and block's size
1538 * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1539 *
1540 * Allocates memory block from the specified NUMA node. If the node
1541 * has no available memory, attempts to allocated from any node in the
1542 * system.
1543 *
1544 * Return: physical address of the allocated memory block on success,
1545 * %0 on failure.
1546 */
1547 phys_addr_t __init memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid)
1548 {
1549 return memblock_alloc_range_nid(size, align, 0,
1550 MEMBLOCK_ALLOC_ACCESSIBLE, nid, false);
1551 }
1552
1553 /**
1554 * memblock_alloc_internal - allocate boot memory block
1555 * @size: size of memory block to be allocated in bytes
1556 * @align: alignment of the region and block's size
1557 * @min_addr: the lower bound of the memory region to allocate (phys address)
1558 * @max_addr: the upper bound of the memory region to allocate (phys address)
1559 * @nid: nid of the free area to find, %NUMA_NO_NODE for any node
1560 * @exact_nid: control the allocation fall back to other nodes
1561 * @flags: alloc memory from specify memblock flag
1562 *
1563 * Allocates memory block using memblock_alloc_range_nid() and
1564 * converts the returned physical address to virtual.
1565 *
1566 * The @min_addr limit is dropped if it can not be satisfied and the allocation
1567 * will fall back to memory below @min_addr. Other constraints, such
1568 * as node and mirrored memory will be handled again in
1569 * memblock_alloc_range_nid().
1570 *
1571 * Return:
1572 * Virtual address of allocated memory block on success, NULL on failure.
1573 */
1574 static void * __init __memblock_alloc_internal(
1575 phys_addr_t size, phys_addr_t align,
1576 phys_addr_t min_addr, phys_addr_t max_addr,
1577 int nid, bool exact_nid,
1578 enum memblock_flags flags)
> 1579 {
1580 phys_addr_t alloc;
1581
1582 /*
1583 * Detect any accidental use of these APIs after slab is ready, as at
1584 * this moment memblock may be deinitialized already and its
1585 * internal data may be destroyed (after execution of memblock_free_all)
1586 */
1587 if (WARN_ON_ONCE(slab_is_available()))
1588 return kzalloc_node(size, GFP_NOWAIT, nid);
1589
1590 if (max_addr > memblock.current_limit)
1591 max_addr = memblock.current_limit;
1592
1593 alloc = memblock_alloc_range_nid_flags(size, align, min_addr, max_addr, nid,
1594 exact_nid, flags);
1595
1596 /* retry allocation without lower limit */
1597 if (!alloc && min_addr)
1598 alloc = memblock_alloc_range_nid_flags(size, align, 0, max_addr, nid,
1599 exact_nid, flags);
1600
1601 if (!alloc)
1602 return NULL;
1603
1604 return phys_to_virt(alloc);
1605 }
1606
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[openeuler:OLK-6.6 1897/1897] mm/madvise.c:297:6: warning: no previous prototype for 'force_swapin_vma'
by kernel test robot 07 Feb '25
by kernel test robot 07 Feb '25
07 Feb '25
Hi Liu,
FYI, the error/warning still remains.
tree: https://gitee.com/openeuler/kernel.git OLK-6.6
head: fdc8c83a12a8fc4b7c55971d552758ffe2f34c14
commit: 92a0eb9bde6c03412b39f9f3d20968c091ea3b46 [1897/1897] memcg: introduce per-memcg swapin interface
config: x86_64-alldefconfig (https://download.01.org/0day-ci/archive/20250207/202502071345.oFOjxkvF-lkp@…)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250207/202502071345.oFOjxkvF-lkp@…)
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(a)intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502071345.oFOjxkvF-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> mm/madvise.c:297:6: warning: no previous prototype for 'force_swapin_vma' [-Wmissing-prototypes]
297 | void force_swapin_vma(struct vm_area_struct *vma)
| ^~~~~~~~~~~~~~~~
vim +/force_swapin_vma +297 mm/madvise.c
280
281 #ifdef CONFIG_MEMCG_SWAP_QOS
282 void force_swapin_vma(struct vm_area_struct *vma)
283 {
284 struct file *file = vma->vm_file;
285
286 if (!can_madv_lru_vma(vma))
287 return;
288
289 if (!file) {
290 walk_page_vma(vma, &swapin_walk_ops, vma);
291 lru_add_drain();
292 } else if (shmem_mapping(file->f_mapping))
293 shmem_swapin_range(vma, vma->vm_start,
294 vma->vm_end, file->f_mapping);
295 }
296 #else
> 297 void force_swapin_vma(struct vm_area_struct *vma)
298 {
299 }
300 #endif
301
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
1
0

[PATCH OLK-6.6] wifi: mac80211: fix mbss changed flags corruption on 32 bit systems
by Wang Wensheng 07 Feb '25
by Wang Wensheng 07 Feb '25
07 Feb '25
From: Issam Hamdi <ih(a)simonwunderlich.de>
stable inclusion
from stable-v6.6.70
commit 86772872f9f5097cd03d0e1c6813238bd38c250b
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBID2X
CVE: CVE-2024-57899
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
--------------------------------
[ Upstream commit 49dba1ded8dd5a6a12748631403240b2ab245c34 ]
On 32-bit systems, the size of an unsigned long is 4 bytes,
while a u64 is 8 bytes. Therefore, when using
or_each_set_bit(bit, &bits, sizeof(changed) * BITS_PER_BYTE),
the code is incorrectly searching for a bit in a 32-bit
variable that is expected to be 64 bits in size,
leading to incorrect bit finding.
Solution: Ensure that the size of the bits variable is correctly
adjusted for each architecture.
Call Trace:
? show_regs+0x54/0x58
? __warn+0x6b/0xd4
? ieee80211_link_info_change_notify+0xcc/0xd4 [mac80211]
? report_bug+0x113/0x150
? exc_overflow+0x30/0x30
? handle_bug+0x27/0x44
? exc_invalid_op+0x18/0x50
? handle_exception+0xf6/0xf6
? exc_overflow+0x30/0x30
? ieee80211_link_info_change_notify+0xcc/0xd4 [mac80211]
? exc_overflow+0x30/0x30
? ieee80211_link_info_change_notify+0xcc/0xd4 [mac80211]
? ieee80211_mesh_work+0xff/0x260 [mac80211]
? cfg80211_wiphy_work+0x72/0x98 [cfg80211]
? process_one_work+0xf1/0x1fc
? worker_thread+0x2c0/0x3b4
? kthread+0xc7/0xf0
? mod_delayed_work_on+0x4c/0x4c
? kthread_complete_and_exit+0x14/0x14
? ret_from_fork+0x24/0x38
? kthread_complete_and_exit+0x14/0x14
? ret_from_fork_asm+0xf/0x14
? entry_INT80_32+0xf0/0xf0
Signed-off-by: Issam Hamdi <ih(a)simonwunderlich.de>
Link: https://patch.msgid.link/20241125162920.2711462-1-ih@simonwunderlich.de
[restore no-op path for no changes]
Signed-off-by: Johannes Berg <johannes.berg(a)intel.com>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Signed-off-by: ZhangPeng <zhangpeng362(a)huawei.com>
Signed-off-by: Wang Wensheng <wangwensheng4(a)huawei.com>
---
net/mac80211/mesh.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
index 25223184d6e5..a5e7edd2f2d1 100644
--- a/net/mac80211/mesh.c
+++ b/net/mac80211/mesh.c
@@ -1173,14 +1173,14 @@ void ieee80211_mbss_info_change_notify(struct ieee80211_sub_if_data *sdata,
u64 changed)
{
struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
- unsigned long bits = changed;
+ unsigned long bits[] = { BITMAP_FROM_U64(changed) };
u32 bit;
- if (!bits)
+ if (!changed)
return;
/* if we race with running work, worst case this work becomes a noop */
- for_each_set_bit(bit, &bits, sizeof(changed) * BITS_PER_BYTE)
+ for_each_set_bit(bit, bits, sizeof(changed) * BITS_PER_BYTE)
set_bit(bit, ifmsh->mbss_changed);
set_bit(MESH_WORK_MBSS_CHANGED, &ifmsh->wrkq_flags);
wiphy_work_queue(sdata->local->hw.wiphy, &sdata->work);
--
2.22.0
2
1