tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 33267d4a7f512d371a3ea853568832174be4caba
commit: 211070f39ed4ec7390dca8351c9fee934b8179e7 [1345/1345] HID: i2c-hid: override HID descriptors for certain devices
config: x86_64-buildonly-randconfig-002-20241224 (https://download.01.org/0day-ci/archive/20241225/202412250406.LdESsxQc-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/20241225/202412250406.LdESsxQc-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/202412250406.LdESsxQc-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/hid/i2c-hid/i2c-hid-core.c:21:
include/linux/module.h:140:14: warning: 'cleanup_module' specifies less restrictive attribute than its target 'i2c_hid_driver_exit': 'cold' [-Wmissing-attributes]
140 | void cleanup_module(void) __attribute__((alias(#exitfn)));
| ^~~~~~~~~~~~~~
include/linux/device.h:1637:1: note: in expansion of macro 'module_exit'
1637 | module_exit(__driver##_exit);
| ^~~~~~~~~~~
include/linux/i2c.h:870:9: note: in expansion of macro 'module_driver'
870 | module_driver(__i2c_driver, i2c_add_driver, \
| ^~~~~~~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:1344:1: note: in expansion of macro 'module_i2c_driver'
1344 | module_i2c_driver(i2c_hid_driver);
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/i2c.h:30,
from drivers/hid/i2c-hid/i2c-hid-core.c:22:
drivers/hid/i2c-hid/i2c-hid-core.c:1344:19: note: 'cleanup_module' target declared here
1344 | module_i2c_driver(i2c_hid_driver);
| ^~~~~~~~~~~~~~
include/linux/device.h:1633:20: note: in definition of macro 'module_driver'
1633 | static void __exit __driver##_exit(void) \
| ^~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:1344:1: note: in expansion of macro 'module_i2c_driver'
1344 | module_i2c_driver(i2c_hid_driver);
| ^~~~~~~~~~~~~~~~~
include/linux/module.h:134:13: warning: 'init_module' specifies less restrictive attribute than its target 'i2c_hid_driver_init': 'cold' [-Wmissing-attributes]
134 | int init_module(void) __attribute__((alias(#initfn)));
| ^~~~~~~~~~~
include/linux/device.h:1632:1: note: in expansion of macro 'module_init'
1632 | module_init(__driver##_init); \
| ^~~~~~~~~~~
include/linux/i2c.h:870:9: note: in expansion of macro 'module_driver'
870 | module_driver(__i2c_driver, i2c_add_driver, \
| ^~~~~~~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:1344:1: note: in expansion of macro 'module_i2c_driver'
1344 | module_i2c_driver(i2c_hid_driver);
| ^~~~~~~~~~~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:1344:19: note: 'init_module' target declared here
1344 | module_i2c_driver(i2c_hid_driver);
| ^~~~~~~~~~~~~~
include/linux/device.h:1628:19: note: in definition of macro 'module_driver'
1628 | static int __init __driver##_init(void) \
| ^~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:1344:1: note: in expansion of macro 'module_i2c_driver'
1344 | module_i2c_driver(i2c_hid_driver);
| ^~~~~~~~~~~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:327: warning: Function parameter or member 'data_len' not described in 'i2c_hid_set_or_send_report'
drivers/hid/i2c-hid/i2c-hid-core.c:327: warning: Excess function parameter 'len' description in 'i2c_hid_set_or_send_report'
drivers/hid/i2c-hid/.tmp_i2c-hid-core.o: warning: objtool: i2c_hid_parse()+0x302: sibling call from callable instruction with modified stack frame
drivers/hid/i2c-hid/.tmp_i2c-hid-core.o: warning: objtool: i2c_hid_probe()+0x20: sibling call from callable instruction with modified stack frame
>> drivers/hid/i2c-hid/.tmp_i2c-hid-core.o: warning: objtool: missing symbol for section .init.text
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 33267d4a7f512d371a3ea853568832174be4caba
commit: 63a07568188f27d31954cf24f43540c9c2fa92cd [1345/1345] arm64: introduce binfmt_elf32.c
config: arm64-randconfig-001-20241224 (https://download.01.org/0day-ci/archive/20241225/202412250053.0bM6RR8q-lkp@…)
compiler: aarch64-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241225/202412250053.0bM6RR8q-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/202412250053.0bM6RR8q-lkp@intel.com/
All errors (new ones prefixed by >>):
aarch64-linux-ld: warning: .tmp_vmlinux1 has a LOAD segment with RWX permissions
aarch64-linux-ld: arch/arm64/kernel/binfmt_elf32.o: in function `elf_core_dump':
>> binfmt_elf32.c:(.text+0x2460): undefined reference to `elf_core_extra_phdrs'
>> binfmt_elf32.c:(.text+0x2460): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `elf_core_extra_phdrs'
>> aarch64-linux-ld: binfmt_elf32.c:(.text+0x2650): undefined reference to `elf_core_extra_data_size'
>> binfmt_elf32.c:(.text+0x2650): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `elf_core_extra_data_size'
>> aarch64-linux-ld: binfmt_elf32.c:(.text+0x27bc): undefined reference to `elf_core_write_extra_phdrs'
>> binfmt_elf32.c:(.text+0x27bc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `elf_core_write_extra_phdrs'
>> aarch64-linux-ld: binfmt_elf32.c:(.text+0x2a88): undefined reference to `elf_core_write_extra_data'
>> binfmt_elf32.c:(.text+0x2a88): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `elf_core_write_extra_data'
aarch64-linux-ld: kernel/sched/cputime.o: in function `sched_idle_time_adjust':
cputime.c:(.text+0xa28): undefined reference to `get_idle_time'
cputime.c:(.text+0xa28): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `get_idle_time'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 33267d4a7f512d371a3ea853568832174be4caba
commit: 451823febcb610969f048556cedc41b5e08fafb1 [1345/1345] UACCE backport from mainline
config: x86_64-buildonly-randconfig-005-20241224 (https://download.01.org/0day-ci/archive/20241225/202412250049.8vKhen0x-lkp@…)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241225/202412250049.8vKhen0x-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/202412250049.8vKhen0x-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/misc/uacce/uacce.c: In function 'numa_distance_show':
drivers/misc/uacce/uacce.c:1032:23: warning: unused variable 'uacce' [-Wunused-variable]
1032 | struct uacce *uacce = UACCE_FROM_CDEV_ATTR(dev);
| ^~~~~
drivers/misc/uacce/uacce.c: In function 'node_id_show':
drivers/misc/uacce/uacce.c:1046:23: warning: unused variable 'uacce' [-Wunused-variable]
1046 | struct uacce *uacce = UACCE_FROM_CDEV_ATTR(dev);
| ^~~~~
drivers/misc/uacce/uacce.c:60: warning: Function parameter or member 'dev' not described in 'dev_to_uacce'
drivers/misc/uacce/uacce.c:81: warning: Function parameter or member 'uacce' not described in 'uacce_hw_err_isolate'
drivers/misc/uacce/uacce.c:140: warning: Function parameter or member 'q' not described in 'uacce_wake_up'
>> drivers/misc/uacce/uacce.o: warning: objtool: missing symbol for section .exit.text
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
tree: https://gitee.com/openeuler/kernel.git openEuler-1.0-LTS
head: 5a23f5b9f615aef1973a9e3894d42c2ddd7364b3
commit: ac084b72b429b1bc0378add3abecfe107a732b7a [1343/1343] iommu: introduce device fault report API
config: arm64-randconfig-r113-20241223 (https://download.01.org/0day-ci/archive/20241224/202412242131.GLZuoZe5-lkp@…)
compiler: aarch64-linux-gcc (GCC) 14.2.0
reproduce: (https://download.01.org/0day-ci/archive/20241224/202412242131.GLZuoZe5-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/202412242131.GLZuoZe5-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/iommu/iommu.c:979:31: sparse: sparse: dubious: !x | !y
drivers/iommu/iommu.c: In function 'iommu_unregister_device_fault_handler':
drivers/iommu/iommu.c:937:13: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
937 | int ret = 0;
| ^~~
In file included from arch/arm64/include/asm/atomic.h:34,
from include/linux/atomic.h:7,
from include/asm-generic/bitops/atomic.h:5,
from arch/arm64/include/asm/bitops.h:37,
from include/linux/bitops.h:19,
from include/linux/kernel.h:11,
from include/linux/list.h:9,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from drivers/iommu/iommu.c:21:
In function '__cmpxchg_case_acq_4',
inlined from '__cmpxchg_acq' at arch/arm64/include/asm/cmpxchg.h:141:1,
inlined from 'queued_spin_lock' at include/asm-generic/qspinlock.h:85:8,
inlined from 'do_raw_spin_lock' at include/linux/spinlock.h:180:2,
inlined from '__raw_spin_lock' at include/linux/spinlock_api_smp.h:143:2,
inlined from 'spin_lock' at include/linux/spinlock.h:329:2,
inlined from 'iommu_device_register' at drivers/iommu/iommu.c:101:2:
arch/arm64/include/asm/atomic_lse.h:458:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'spinlock_t[1]' {aka 'struct spinlock[1]'} [-Warray-bounds=]
458 | asm volatile(ARM64_LSE_ATOMIC_INSN( 25- | ^~~
arch/arm64/include/asm/atomic_lse.h:479:1: note: in expansion of macro '__CMPXCHG_CASE'
479 | __CMPXCHG_CASE(w, , acq_4, a, "memory")
| ^~~~~~~~~~~~~~
In file included from include/linux/mutex.h:16,
from include/linux/kernfs.h:14,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:21:
drivers/iommu/iommu.c: In function 'iommu_device_register':
drivers/iommu/iommu.c:97:24: note: object 'iommu_device_lock' of size 4
97 | static DEFINE_SPINLOCK(iommu_device_lock);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock_types.h:81:44: note: in definition of macro 'DEFINE_SPINLOCK'
81 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
| ^
In function '__cmpxchg_case_acq_4',
inlined from '__cmpxchg_acq' at arch/arm64/include/asm/cmpxchg.h:141:1,
inlined from 'queued_spin_lock' at include/asm-generic/qspinlock.h:85:8,
inlined from 'do_raw_spin_lock' at include/linux/spinlock.h:180:2,
inlined from '__raw_spin_lock' at include/linux/spinlock_api_smp.h:143:2,
inlined from 'spin_lock' at include/linux/spinlock.h:329:2,
inlined from 'iommu_device_register' at drivers/iommu/iommu.c:101:2:
arch/arm64/include/asm/atomic_lse.h:458:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'spinlock_t[1]' {aka 'struct spinlock[1]'} [-Warray-bounds=]
458 | asm volatile(ARM64_LSE_ATOMIC_INSN( 49- | ^~~
arch/arm64/include/asm/atomic_lse.h:479:1: note: in expansion of macro '__CMPXCHG_CASE'
479 | __CMPXCHG_CASE(w, , acq_4, a, "memory")
| ^~~~~~~~~~~~~~
drivers/iommu/iommu.c: In function 'iommu_device_register':
drivers/iommu/iommu.c:97:24: note: object 'iommu_device_lock' of size 4
97 | static DEFINE_SPINLOCK(iommu_device_lock);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock_types.h:81:44: note: in definition of macro 'DEFINE_SPINLOCK'
81 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
| ^
In function '__cmpxchg_case_acq_4',
inlined from '__cmpxchg_acq' at arch/arm64/include/asm/cmpxchg.h:141:1,
inlined from 'queued_spin_lock' at include/asm-generic/qspinlock.h:85:8,
inlined from 'do_raw_spin_lock' at include/linux/spinlock.h:180:2,
inlined from '__raw_spin_lock' at include/linux/spinlock_api_smp.h:143:2,
inlined from 'spin_lock' at include/linux/spinlock.h:329:2,
inlined from 'iommu_device_unregister' at drivers/iommu/iommu.c:110:2:
arch/arm64/include/asm/atomic_lse.h:458:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'spinlock_t[1]' {aka 'struct spinlock[1]'} [-Warray-bounds=]
458 | asm volatile(ARM64_LSE_ATOMIC_INSN( 69- | ^~~
arch/arm64/include/asm/atomic_lse.h:479:1: note: in expansion of macro '__CMPXCHG_CASE'
479 | __CMPXCHG_CASE(w, , acq_4, a, "memory")
| ^~~~~~~~~~~~~~
drivers/iommu/iommu.c: In function 'iommu_device_unregister':
drivers/iommu/iommu.c:97:24: note: object 'iommu_device_lock' of size 4
97 | static DEFINE_SPINLOCK(iommu_device_lock);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock_types.h:81:44: note: in definition of macro 'DEFINE_SPINLOCK'
81 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
| ^
In function '__cmpxchg_case_acq_4',
inlined from '__cmpxchg_acq' at arch/arm64/include/asm/cmpxchg.h:141:1,
inlined from 'queued_spin_lock' at include/asm-generic/qspinlock.h:85:8,
inlined from 'do_raw_spin_lock' at include/linux/spinlock.h:180:2,
inlined from '__raw_spin_lock' at include/linux/spinlock_api_smp.h:143:2,
inlined from 'spin_lock' at include/linux/spinlock.h:329:2,
inlined from 'iommu_device_unregister' at drivers/iommu/iommu.c:110:2:
arch/arm64/include/asm/atomic_lse.h:458:9: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'spinlock_t[1]' {aka 'struct spinlock[1]'} [-Warray-bounds=]
458 | asm volatile(ARM64_LSE_ATOMIC_INSN( 89- | ^~~
arch/arm64/include/asm/atomic_lse.h:479:1: note: in expansion of macro '__CMPXCHG_CASE'
479 | __CMPXCHG_CASE(w, , acq_4, a, "memory")
| ^~~~~~~~~~~~~~
drivers/iommu/iommu.c: In function 'iommu_device_unregister':
drivers/iommu/iommu.c:97:24: note: object 'iommu_device_lock' of size 4
97 | static DEFINE_SPINLOCK(iommu_device_lock);
| ^~~~~~~~~~~~~~~~~
include/linux/spinlock_types.h:81:44: note: in definition of macro 'DEFINE_SPINLOCK'
81 | #define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
| ^
In function '__cmpxchg_case_acq_4',
inlined from '__cmpxchg_acq' at arch/arm64/include/asm/cmpxchg.h:141:1,
vim +979 drivers/iommu/iommu.c
960
961
962 /**
963 * iommu_report_device_fault() - Report fault event to device
964 * @dev: the device
965 * @evt: fault event data
966 *
967 * Called by IOMMU model specific drivers when fault is detected, typically
968 * in a threaded IRQ handler.
969 *
970 * Return 0 on success, or an error.
971 */
972 int iommu_report_device_fault(struct device *dev, struct iommu_fault_event *evt)
973 {
974 int ret = 0;
975 struct iommu_fault_event *evt_pending;
976 struct iommu_fault_param *fparam;
977
978 /* iommu_param is allocated when device is added to group */
> 979 if (!dev->iommu_param | !evt)
980 return -EINVAL;
981 /* we only report device fault if there is a handler registered */
982 mutex_lock(&dev->iommu_param->lock);
983 if (!dev->iommu_param->fault_param ||
984 !dev->iommu_param->fault_param->handler) {
985 ret = -EINVAL;
986 goto done_unlock;
987 }
988 fparam = dev->iommu_param->fault_param;
989 if (evt->type == IOMMU_FAULT_PAGE_REQ && evt->last_req) {
990 evt_pending = kzalloc(sizeof(*evt_pending), GFP_ATOMIC);
991 if (!evt_pending) {
992 ret = -ENOMEM;
993 goto done_unlock;
994 }
995 memcpy(evt_pending, evt, sizeof(struct iommu_fault_event));
996 mutex_lock(&fparam->lock);
997 list_add_tail(&evt_pending->list, &fparam->faults);
998 mutex_unlock(&fparam->lock);
999 }
1000 ret = fparam->handler(evt, fparam->data);
1001 done_unlock:
1002 mutex_unlock(&dev->iommu_param->lock);
1003 return ret;
1004 }
1005 EXPORT_SYMBOL_GPL(iommu_report_device_fault);
1006
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBDF90
--------------------------------
While we split/merge page in dynamic pool, the refcount of page may be
increased to 1 due to prep_new_page(), and we then set the refcount to 0.
That means there's a time window that the refcount of the free page is
not 0.
split_huge_pages_set() will scan all pages and try to get the refcount
If try to get refcount in the above time window and put_page() after
the refcount is set to 0, the refcount will be decreased to -1.
It's dangerous if the refcount for page is not 0 when split/merge, so try
not to get refcount there.
Fixes: 0bc0d0d57eda ("dhugetlb: backport dynamic hugetlb feature")
Signed-off-by: Liu Shixin <liushixin2(a)huawei.com>
---
mm/hugetlb.c | 4 ++--
mm/internal.h | 4 ++++
mm/page_alloc.c | 26 ++++++++++++++++++++++++++
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 82a758bb8ac9..191ed8a6b0d0 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3575,8 +3575,8 @@ static void add_new_huge_page_to_pool(struct dhugetlb_pool *hpool,
list_add_tail(&page->lru, &hpool->dhugetlb_1G_freelists);
hpool->free_unreserved_1G++;
} else {
- prep_new_page(page, PMD_SHIFT - PAGE_SHIFT, __GFP_COMP, 0);
- set_page_count(page, 0);
+ prep_new_frozen_free_page(page, PMD_SHIFT - PAGE_SHIFT,
+ __GFP_COMP);
list_add_tail(&page->lru, &hpool->dhugetlb_2M_freelists);
hpool->free_unreserved_2M++;
}
diff --git a/mm/internal.h b/mm/internal.h
index 72f77379b58f..e50363ddb416 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -185,6 +185,10 @@ extern void prep_compound_page(struct page *page, unsigned int order);
extern int check_new_page(struct page *page);
extern void post_alloc_hook(struct page *page, unsigned int order,
gfp_t gfp_flags);
+#ifdef CONFIG_DYNAMIC_HUGETLB
+extern void prep_new_frozen_free_page(struct page *page, unsigned int order,
+ gfp_t gfp_flags);
+#endif
extern int user_min_free_kbytes;
#if defined CONFIG_COMPACTION || defined CONFIG_CMA
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index e2360fe3616d..787bbabc29d0 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2100,6 +2100,32 @@ void prep_new_page(struct page *page, unsigned int order, gfp_t gfp_flags,
clear_page_pfmemalloc(page);
}
+#ifdef CONFIG_DYNAMIC_HUGETLB
+/* Similar with prep_new_page without set refcount to 1 */
+void prep_new_frozen_free_page(struct page *page, unsigned int order,
+ gfp_t gfp_flags)
+{
+ int i;
+
+ set_page_private(page, 0);
+
+ arch_alloc_page(page, order);
+ kernel_map_pages(page, 1 << order, 1);
+ kasan_alloc_pages(page, order);
+ kernel_poison_pages(page, 1 << order, 1);
+ set_page_owner(page, order, gfp_flags);
+
+ if (!free_pages_prezeroed() && (gfp_flags & __GFP_ZERO))
+ for (i = 0; i < (1 << order); i++)
+ clear_highpage(page + i);
+
+ if (order && (gfp_flags & __GFP_COMP))
+ prep_compound_page(page, order);
+
+ clear_page_pfmemalloc(page);
+}
+#endif
+
/*
* Go through the free lists for the given migratetype and remove
* the smallest available page from the freelists
--
2.34.1
From: Armin Wolf <W_Armin(a)gmx.de>
stable inclusion
from stable-v4.19.323
commit 76fb2cbf01571926da8ecf6876cc8cb07d3f5183
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBBN6V
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id…
-------------------------------------------------------------
[ Upstream commit 76959aff14a0012ad6b984ec7686d163deccdc16 ]
When a battery hook returns an error when adding a new battery, then
the battery hook is automatically unregistered.
However the battery hook provider cannot know that, so it will later
call battery_hook_unregister() on the already unregistered battery
hook, resulting in a crash.
Fix this by using the list head to mark already unregistered battery
hooks as already being unregistered so that they can be ignored by
battery_hook_unregister().
Fixes: fa93854f7a7e ("battery: Add the battery hooking API")
Signed-off-by: Armin Wolf <W_Armin(a)gmx.de>
Link: https://patch.msgid.link/20241001212835.341788-3-W_Armin@gmx.de
Cc: All applicable <stable(a)vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki(a)intel.com>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
Signed-off-by: Heyuan Wang <wangheyuan2(a)h-partners.com>
---
drivers/acpi/battery.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b741ed87ab3d..46aa0e5e6f8b 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -724,7 +724,7 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
list_for_each_entry(battery, &acpi_battery_list, list) {
hook->remove_battery(battery->bat);
}
- list_del(&hook->list);
+ list_del_init(&hook->list);
pr_info("extension unregistered: %s\n", hook->name);
}
@@ -732,7 +732,14 @@ static void battery_hook_unregister_unlocked(struct acpi_battery_hook *hook)
void battery_hook_unregister(struct acpi_battery_hook *hook)
{
mutex_lock(&hook_mutex);
- battery_hook_unregister_unlocked(hook);
+ /*
+ * Ignore already unregistered battery hooks. This might happen
+ * if a battery hook was previously unloaded due to an error when
+ * adding a new battery.
+ */
+ if (!list_empty(&hook->list))
+ battery_hook_unregister_unlocked(hook);
+
mutex_unlock(&hook_mutex);
}
EXPORT_SYMBOL_GPL(battery_hook_unregister);
@@ -742,7 +749,6 @@ void battery_hook_register(struct acpi_battery_hook *hook)
struct acpi_battery *battery;
mutex_lock(&hook_mutex);
- INIT_LIST_HEAD(&hook->list);
list_add(&hook->list, &battery_hook_list);
/*
* Now that the driver is registered, we need
--
2.25.1