yangsong8-a1 opened a new pull request, #22085:
URL: https://github.com/apache/nuttx/pull/22085

   ## Summary
     
     With a report interval set (BATIOC_SET_DEBOUNCE), the charger, gauge
     and monitor upper halves queue their notify work on LPWORK.  Their
     close() handlers freed priv without cancelling that work, so the work
     could run after close() and dereference the freed priv.  Cancel it
     with work_cancel_sync() before freeing.
     
     ## Impact
     
     drivers/power/battery: battery_charger.c, battery_gauge.c,
     battery_monitor.c.  No API change.
     
     ## Testing
     
     Ubuntu 22.04, gcc 13.1, sim:nsh with CONFIG_BATTERY_GAUGE=y,
     CONFIG_MM_KASAN=y and CONFIG_MM_KASAN_ALL=y.  A test program registers
     a fake gauge, opens it, sets the debounce interval to 20 ticks,
     reports a capacity change so the notify work is queued, closes the fd
     and waits 500 ms; three rounds.
     
     master (KASAN report in the work thread right after the first close):
     
     nsh> hello
     register: 0
     round 0: fd 3 debounce 0, closed with work pending
     kasan_report: kasan detected a read access error, address at 
0x772606524038,size is 8, return address: 0x40023f33
     ...
     dump_assert_info: Assertion failed panic: at file: :0 task: hpwork 
process: Kernel 0x400244a9
     
     This PR:
     
     nsh> hello
     register: 0
     round 0: fd 3 debounce 0, closed with work pending
     round 1: fd 3 debounce 0, closed with work pending
     round 2: fd 3 debounce 0, closed with work pending
     done
     
     ````
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to