mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 01/15] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages()
@ 2021-07-04 23:12 Sasha Levin
  2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 02/15] spi: omap-100k: Fix the length judgment problem Sasha Levin
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Sasha Levin @ 2021-07-04 23:12 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Jay Fang, Mark Brown, Sasha Levin, linux-spi

From: Jay Fang <f.fangjian@huawei.com>

[ Upstream commit 026a1dc1af52742c5897e64a3431445371a71871 ]

pch_spi_set_tx() frees data->pkt_tx_buff on failure of kzalloc() for
data->pkt_rx_buff, but its caller, pch_spi_process_messages(), will
free data->pkt_tx_buff again. Set data->pkt_tx_buff to NULL after
kfree() to avoid double free.

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1620284888-65215-1-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-topcliff-pch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 9f30a4ab2004..66c170e799fc 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -589,8 +589,10 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
 	if (data->pkt_tx_buff != NULL) {
 		data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
-		if (!data->pkt_rx_buff)
+		if (!data->pkt_rx_buff) {
 			kfree(data->pkt_tx_buff);
+			data->pkt_tx_buff = NULL;
+		}
 	}
 
 	if (!data->pkt_rx_buff) {
-- 
2.30.2


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-07-04 23:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 23:12 [PATCH AUTOSEL 4.4 01/15] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 02/15] spi: omap-100k: Fix the length judgment problem Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 03/15] crypto: nx - add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 04/15] media: cpia2: fix memory leak in cpia2_usb_probe Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 05/15] media: pvrusb2: fix warning in pvr2_i2c_core_done Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 06/15] crypto: qat - check return code of qat_hal_rd_rel_reg() Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 07/15] crypto: qat - remove unused macro in FW loader Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 08/15] media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 09/15] media: bt8xx: Fix a missing check bug in bt878_probe Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 10/15] mmc: via-sdmmc: add a check against NULL pointer dereference Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 11/15] crypto: shash - avoid comparing pointers to exported functions under CFI Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 12/15] media: dvb_net: avoid speculation from net slot Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 13/15] btrfs: make Private2 lifespan more consistent Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 14/15] btrfs: disable build on platforms having page size 256K Sasha Levin
2021-07-04 23:12 ` [PATCH AUTOSEL 4.4 15/15] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®