linux-stable/drivers/char
Zhang Yuchen 3fa7cbdbe3 ipmi: fix memleak when unload ipmi driver
[ Upstream commit 36992eb6b9 ]

After the IPMI disconnect problem, the memory kept rising and we tried
to unload the driver to free the memory. However, only part of the
free memory is recovered after the driver is uninstalled. Using
ebpf to hook free functions, we find that neither ipmi_user nor
ipmi_smi_msg is free, only ipmi_recv_msg is free.

We find that the deliver_smi_err_response call in clean_smi_msgs does
the destroy processing on each message from the xmit_msg queue without
checking the return value and free ipmi_smi_msg.

deliver_smi_err_response is called only at this location. Adding the
free handling has no effect.

To verify, try using ebpf to trace the free function.

  $ bpftrace -e 'kretprobe:ipmi_alloc_recv_msg {printf("alloc rcv
      %p\n",retval);} kprobe:free_recv_msg {printf("free recv %p\n",
      arg0)} kretprobe:ipmi_alloc_smi_msg {printf("alloc smi %p\n",
        retval);} kprobe:free_smi_msg {printf("free smi  %p\n",arg0)}'

Signed-off-by: Zhang Yuchen <zhangyuchen.lcr@bytedance.com>
Message-Id: <20221007092617.87597-4-zhangyuchen.lcr@bytedance.com>
[Fixed the comment above handle_one_recv_msg().]
Signed-off-by: Corey Minyard <cminyard@mvista.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-01-07 12:07:31 +01:00
..
agp parisc/agp: Annotate parisc agp init functions with __init 2021-12-22 09:05:13 +01:00
hw_random hwrng: geode - Fix PCI device refcount leak 2023-01-07 12:07:24 +01:00
ipmi ipmi: fix memleak when unload ipmi driver 2023-01-07 12:07:31 +01:00
mwave char/mwave: Adjust io port register size 2022-01-27 08:47:35 +01:00
pcmcia char: pcmcia: error out if 'num_bytes_read' is greater than 4 in set_protocol() 2021-07-20 16:21:04 +02:00
tpm tpm: ibmvtpm: Correct the return value in tpm_ibmvtpm_probe() 2022-06-06 08:19:46 +02:00
xilinx_hwicap
xillybus
Kconfig random: credit cpu and bootloader seeds by default 2022-06-25 11:45:17 +02:00
Makefile
apm-emulation.c
applicom.c applicom: Fix potential Spectre v1 vulnerabilities 2019-03-13 14:04:54 -07:00
applicom.h
bfin-otp.c
bsr.c
ds1302.c
ds1620.c
dsp56k.c
dtlk.c
efirtc.c
generic_nvram.c
hangcheck-timer.c
hpet.c char: hpet: add checks after calling ioremap 2021-06-03 08:23:31 +02:00
lp.c char: lp: fix possible integer overflow in lp_setup() 2017-05-25 15:44:30 +02:00
mbcs.c
mbcs.h
mem.c /dev/mem: Bail out upon SIGKILL. 2019-10-05 12:30:35 +02:00
misc.c
mmtimer.c
mspec.c
nsc_gpio.c
nvram.c
nwbutton.c
nwbutton.h
nwflash.c
pc8736x_gpio.c
powernv-op-panel.c
ppdev.c ppdev: fix PPGETTIME/PPSETTIME ioctls 2019-12-21 10:42:07 +01:00
ps3flash.c
random.c random: use expired timer rather than wq for mixing fast pool 2022-10-26 13:15:36 +02:00
raw.c
rtc.c
scx200_gpio.c
snsc.c
snsc.h
snsc_event.c
sonypi.c
tb0219.c
tile-srom.c
tlclk.c drivers: char: tlclk.c: Avoid data race between init and interrupt handler 2020-10-01 20:40:12 +02:00
toshiba.c
ttyprintk.c ttyprintk: Add TTY hangup callback. 2021-05-22 10:40:25 +02:00
uv_mmtimer.c
virtio_console.c virtio_console: eliminate anonymous module_init & module_exit 2022-04-20 09:06:43 +02:00