public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ice: Fix potential memory leak in ice_gnss_tty_write()
@ 2022-12-07  8:55 Yuan Can
  2022-12-07  9:15 ` Leon Romanovsky
  2023-01-05  5:51 ` [Intel-wired-lan] " G, GurucharanX
  0 siblings, 2 replies; 3+ messages in thread
From: Yuan Can @ 2022-12-07  8:55 UTC (permalink / raw)
  To: jesse.brandeburg, anthony.l.nguyen, davem, edumazet, kuba, pabeni,
	karol.kolacinski, intel-wired-lan, netdev
  Cc: yuancan

The ice_gnss_tty_write() return directly if the write_buf alloc failed,
leaking the cmd_buf.

Fix by free cmd_buf if write_buf alloc failed.

Fixes: d6b98c8d242a ("ice: add write functionality for GNSS TTY")
Signed-off-by: Yuan Can <yuancan@huawei.com>
---
 drivers/net/ethernet/intel/ice/ice_gnss.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_gnss.c b/drivers/net/ethernet/intel/ice/ice_gnss.c
index b5a7f246d230..a1915551c69a 100644
--- a/drivers/net/ethernet/intel/ice/ice_gnss.c
+++ b/drivers/net/ethernet/intel/ice/ice_gnss.c
@@ -363,6 +363,7 @@ ice_gnss_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 	/* Send the data out to a hardware port */
 	write_buf = kzalloc(sizeof(*write_buf), GFP_KERNEL);
 	if (!write_buf) {
+		kfree(cmd_buf);
 		err = -ENOMEM;
 		goto exit;
 	}
-- 
2.17.1


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

end of thread, other threads:[~2023-01-05  5:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07  8:55 [PATCH net] ice: Fix potential memory leak in ice_gnss_tty_write() Yuan Can
2022-12-07  9:15 ` Leon Romanovsky
2023-01-05  5:51 ` [Intel-wired-lan] " G, GurucharanX

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