diff mbox series

net/virtio: fix getline memory leakage

Message ID 1618969069-15304-1-git-send-email-humin29@huawei.com (mailing list archive)
State Accepted
Delegated to: Maxime Coquelin
Headers show
Series net/virtio: fix getline memory leakage | expand

Checks

Context Check Description
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success travis build: passed
ci/checkpatch success coding style OK

Commit Message

Min Hu (Connor) April 21, 2021, 1:37 a.m. UTC
From: Chengwen Feng <fengchengwen@huawei.com>

This patch fixes getline memory leakage when parsing dynamic major num.

Fixes: 7d62bf6f54ba ("net/virtio: introduce vhost-vDPA backend type")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/virtio/virtio_user_ethdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chenbo Xia April 21, 2021, 2:10 a.m. UTC | #1
> -----Original Message-----
> From: Min Hu (Connor) <humin29@huawei.com>
> Sent: Wednesday, April 21, 2021 9:38 AM
> To: dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; maxime.coquelin@redhat.com; Xia,
> Chenbo <chenbo.xia@intel.com>
> Subject: [PATCH] net/virtio: fix getline memory leakage
> 
> From: Chengwen Feng <fengchengwen@huawei.com>
> 
> This patch fixes getline memory leakage when parsing dynamic major num.
> 
> Fixes: 7d62bf6f54ba ("net/virtio: introduce vhost-vDPA backend type")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
>  drivers/net/virtio/virtio_user_ethdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 79bd31e..e85906e 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -360,7 +360,7 @@ vdpa_dynamic_major_num(void)
>  {
>  	FILE *fp;
>  	char *line = NULL;
> -	size_t size;
> +	size_t size = 0;
>  	char name[11];
>  	bool found = false;
>  	uint32_t num;
> @@ -380,6 +380,7 @@ vdpa_dynamic_major_num(void)
>  			break;
>  		}
>  	}
> +	free(line);
>  	fclose(fp);
>  	return found ? num : UNNAMED_MAJOR;
>  }
> --
> 2.7.4

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Chenbo Xia April 28, 2021, 3:21 a.m. UTC | #2
> -----Original Message-----
> From: stable <stable-bounces@dpdk.org> On Behalf Of Xia, Chenbo
> Sent: Wednesday, April 21, 2021 10:10 AM
> To: Min Hu (Connor) <humin29@huawei.com>; dev@dpdk.org
> Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; maxime.coquelin@redhat.com;
> stable@dpdk.org
> Subject: Re: [dpdk-stable] [PATCH] net/virtio: fix getline memory leakage
> 
> > -----Original Message-----
> > From: Min Hu (Connor) <humin29@huawei.com>
> > Sent: Wednesday, April 21, 2021 9:38 AM
> > To: dev@dpdk.org
> > Cc: Yigit, Ferruh <ferruh.yigit@intel.com>; maxime.coquelin@redhat.com; Xia,
> > Chenbo <chenbo.xia@intel.com>
> > Subject: [PATCH] net/virtio: fix getline memory leakage
> >
> > From: Chengwen Feng <fengchengwen@huawei.com>
> >
> > This patch fixes getline memory leakage when parsing dynamic major num.
> >
> > Fixes: 7d62bf6f54ba ("net/virtio: introduce vhost-vDPA backend type")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> > Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> > ---
> >  drivers/net/virtio/virtio_user_ethdev.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> > b/drivers/net/virtio/virtio_user_ethdev.c
> > index 79bd31e..e85906e 100644
> > --- a/drivers/net/virtio/virtio_user_ethdev.c
> > +++ b/drivers/net/virtio/virtio_user_ethdev.c
> > @@ -360,7 +360,7 @@ vdpa_dynamic_major_num(void)
> >  {
> >  	FILE *fp;
> >  	char *line = NULL;
> > -	size_t size;
> > +	size_t size = 0;
> >  	char name[11];
> >  	bool found = false;
> >  	uint32_t num;
> > @@ -380,6 +380,7 @@ vdpa_dynamic_major_num(void)
> >  			break;
> >  		}
> >  	}
> > +	free(line);
> >  	fclose(fp);
> >  	return found ? num : UNNAMED_MAJOR;
> >  }
> > --
> > 2.7.4

Applied to next-virtio/main, thanks
diff mbox series

Patch

diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index 79bd31e..e85906e 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -360,7 +360,7 @@  vdpa_dynamic_major_num(void)
 {
 	FILE *fp;
 	char *line = NULL;
-	size_t size;
+	size_t size = 0;
 	char name[11];
 	bool found = false;
 	uint32_t num;
@@ -380,6 +380,7 @@  vdpa_dynamic_major_num(void)
 			break;
 		}
 	}
+	free(line);
 	fclose(fp);
 	return found ? num : UNNAMED_MAJOR;
 }