[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220716192336.ccxwopvaurtcef4p@mercury.elektranox.org>
Date: Sat, 16 Jul 2022 21:23:36 +0200
From: Sebastian Reichel <sebastian.reichel@...labora.com>
To: Zheyu Ma <zheyuma97@...il.com>
Cc: t.schramm@...jaro.org, linux-pm@...r.kernel.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [BUG] power: supply: cw2015: Found a bug when removing the module
Hi,
On Sat, Jul 16, 2022 at 04:50:08PM +0800, Zheyu Ma wrote:
> I found a bug in the cw2015 driver.
>
> When I insmod the kernel module, I get the following log:
>
> [ 199.445154] cw2015 0-0010: probe
> [ 199.445447] cw2015 0-0010: No battery-profile found, using current
> flash contents
> [ 199.447198] cw2015 0-0010: Can't check current battery profile, no
> profile provided
> [ 199.448577] cw2015 0-0010: No monitored battery, some properties
> will be missing
> [ 199.449556] i2c-core: driver [cw2015] registered
> [ 199.482970] cw2015 0-0010: No profile specified, continuing without profile
> [ 199.486086] cw2015 0-0010: Failed to get supply state: -19
>
> And when I remove the module, I got the following warning:
>
> [ 200.470198] cw2015 0-0010: remove
> [ 200.471445] ------------[ cut here ]------------
> [ 200.472752] WARNING: CPU: 0 PID: 413 at drivers/base/devres.c:1058
> devm_kfree+0x2a8/0x330
> [ 200.478314] RIP: 0010:devm_kfree+0x2a8/0x330
> [ 200.485019] Call Trace:
> [ 200.485226] <TASK>
> [ 200.485405] ? power_supply_put_battery_info+0xc2/0xe0
> [ 200.486169] cw_bat_remove+0x89/0xa0 [cw2015_battery]
> [ 200.486570] i2c_device_remove+0x181/0x1f0
>
> I think the problem is that the driver fails to call the function
> power_supply_get_battery_info(). However, when removing the module,
> the driver executes power_supply_put_battery_info(), causing a
> warning.
Indeed that seems to happen. Easiest solution is to remove the call
to power_supply_put_battery_info(), because power_supply_get_battery_info()
is now using device managed memory allocation for everything and memory
will be free'd automatically when the device is removed. Can one of you
send a patch for that, since I cannot test it due to lack of hardware?
Also while at it maybe use 'devm_delayed_work_autocancel()' instead
of 'INIT_DELAYED_WORK', so that all resources are device managed and
the remove function can be removed.
> Since I'm not familiar with this driver, I will just report the bug to you.
>
> regards,
>
> Zheyu Ma
Thanks,
-- Sebastian
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists