lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1447925429.2966.2.camel@localhost>
Date:	Thu, 19 Nov 2015 09:30:30 +0000
From:	"Wei, Jiangang" <weijg.fnst@...fujitsu.com>
To:	"r.baldyga@...sung.com" <r.baldyga@...sung.com>
CC:	"standby24x7@...il.com" <standby24x7@...il.com>,
	"rdunlap@...radead.org" <rdunlap@...radead.org>,
	"balbi@...com" <balbi@...com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"jkosina@...e.cz" <jkosina@...e.cz>
Subject: Re: [PATCH] tools: ffs-aio-example: free memory upon failure

On Wed, 2015-11-18 at 10:46 +0100, Robert Baldyga wrote:
> Hi Wei,
> 
> On 11/18/2015 07:13 AM, Wei, Jiangang wrote:
> > To whom it may concern:
> > 
> > Sorry to bother again,
> > But any comment about this patch?
> > 
> 
> Reviewed-by: Robert Baldyga <r.baldyga@...sung.com>
> 
> It looks good to me. By the way, maybe we should also close file
> descriptors in error path?

Thanks for your kindness and comments,
I update it and send the v2.
If you have any other advice, Please let me know.

Thanks,
wei
> 
> Thanks,
> Robert Baldyga
> 
> > On Mon, 2015-11-09 at 14:16 +0800, Wei Jiangang wrote:
> >> Free buffer to avoid memory leak upon failure occurs.
> >>
> >> Signed-off-by: Wei Jiangang <weijg.fnst@...fujitsu.com>
> >> ---
> >>  tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c | 4 ++++
> >>  tools/usb/ffs-aio-example/simple/device_app/aio_simple.c       | 4 ++++
> >>  2 files changed, 8 insertions(+)
> >>
> >> diff --git a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
> >> index aaca1f44e788..3eb1a92baacf 100644
> >> --- a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
> >> +++ b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
> >> @@ -263,20 +263,24 @@ int main(int argc, char *argv[])
> >>  	sprintf(ep_path, "%s/ep0", argv[1]);
> >>  	ep0 = open(ep_path, O_RDWR);
> >>  	if (ep0 < 0) {
> >> +		free(ep_path);
> >>  		perror("unable to open ep0");
> >>  		return 1;
> >>  	}
> >>  	if (write(ep0, &descriptors, sizeof(descriptors)) < 0) {
> >> +		free(ep_path);
> >>  		perror("unable do write descriptors");
> >>  		return 1;
> >>  	}
> >>  	if (write(ep0, &strings, sizeof(strings)) < 0) {
> >> +		free(ep_path);
> >>  		perror("unable to write strings");
> >>  		return 1;
> >>  	}
> >>  	sprintf(ep_path, "%s/ep1", argv[1]);
> >>  	ep1 = open(ep_path, O_RDWR);
> >>  	if (ep1 < 0) {
> >> +		free(ep_path);
> >>  		perror("unable to open ep1");
> >>  		return 1;
> >>  	}
> >> diff --git a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
> >> index 1f44a29818bf..ac96892ca5d2 100644
> >> --- a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
> >> +++ b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
> >> @@ -234,14 +234,17 @@ int main(int argc, char *argv[])
> >>  	sprintf(ep_path, "%s/ep0", argv[1]);
> >>  	ep0 = open(ep_path, O_RDWR);
> >>  	if (ep0 < 0) {
> >> +		free(ep_path);
> >>  		perror("unable to open ep0");
> >>  		return 1;
> >>  	}
> >>  	if (write(ep0, &descriptors, sizeof(descriptors)) < 0) {
> >> +		free(ep_path);
> >>  		perror("unable do write descriptors");
> >>  		return 1;
> >>  	}
> >>  	if (write(ep0, &strings, sizeof(strings)) < 0) {
> >> +		free(ep_path);
> >>  		perror("unable to write strings");
> >>  		return 1;
> >>  	}
> >> @@ -249,6 +252,7 @@ int main(int argc, char *argv[])
> >>  		sprintf(ep_path, "%s/ep%d", argv[1], i+1);
> >>  		ep[i] = open(ep_path, O_RDWR);
> >>  		if (ep[i] < 0) {
> >> +			free(ep_path);
> >>  			printf("unable to open ep%d: %s\n", i+1,
> >>  			       strerror(errno));
> >>  			return 1;
> > 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ