mfd: pcf50633-adc: Fix potential memleak in pcf50633_adc_async_read()
authorQiheng Lin <linqiheng@huawei.com>
Thu, 8 Dec 2022 06:15:55 +0000 (14:15 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:39:34 +0000 (09:39 +0100)
commit6a8a02dcfae13ab07dc7bed2b409cec7f3d32e92
treed8d406ece9327c8021884db17ce51c820136087a
parent413f8b1f8be6b039ef8bbfc7199ad2872d466f9b
mfd: pcf50633-adc: Fix potential memleak in pcf50633_adc_async_read()

[ Upstream commit 8b450dcff23aa254844492831a8e2b508a9d522d ]

`req` is allocated in pcf50633_adc_async_read(), but
adc_enqueue_request() could fail to insert the `req` into queue.
We need to check the return value and free it in the case of failure.

Fixes: 08c3e06a5eb2 ("mfd: PCF50633 adc driver")
Signed-off-by: Qiheng Lin <linqiheng@huawei.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20221208061555.8776-1-linqiheng@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mfd/pcf50633-adc.c