Message ID | 20221207085502.124810-1-yuancan@huawei.com (mailing list archive) |
---|---|
State | Awaiting Upstream |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] ice: Fix potential memory leak in ice_gnss_tty_write() | expand |
On Wed, Dec 07, 2022 at 08:55:02AM +0000, Yuan Can wrote: > 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(+) > Thanks, Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
> -----Original Message----- > From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of > Yuan Can > Sent: Wednesday, December 7, 2022 2:25 PM > To: Brandeburg, Jesse <jesse.brandeburg@intel.com>; Nguyen, Anthony L > <anthony.l.nguyen@intel.com>; davem@davemloft.net; > edumazet@google.com; kuba@kernel.org; pabeni@redhat.com; Kolacinski, > Karol <karol.kolacinski@intel.com>; intel-wired-lan@lists.osuosl.org; > netdev@vger.kernel.org > Cc: yuancan@huawei.com > Subject: [Intel-wired-lan] [PATCH net] ice: Fix potential memory leak in > ice_gnss_tty_write() > > 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(+) > Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
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; }
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(+)