From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933685AbbKSJag (ORCPT ); Thu, 19 Nov 2015 04:30:36 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:61338 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750977AbbKSJad (ORCPT ); Thu, 19 Nov 2015 04:30:33 -0500 X-IronPort-AV: E=Sophos;i="5.20,242,1444665600"; d="scan'208";a="623478" From: "Wei, Jiangang" To: "r.baldyga@samsung.com" CC: "standby24x7@gmail.com" , "rdunlap@infradead.org" , "balbi@ti.com" , "linux-kernel@vger.kernel.org" , "jkosina@suse.cz" Subject: Re: [PATCH] tools: ffs-aio-example: free memory upon failure Thread-Topic: [PATCH] tools: ffs-aio-example: free memory upon failure Thread-Index: AQHRGrY9ZnQMbd91nU+xmCyH93OB6J6g1PqAgAA7W4CAAY39gA== Date: Thu, 19 Nov 2015 09:30:30 +0000 Message-ID: <1447925429.2966.2.camel@localhost> References: <1447049776-23413-1-git-send-email-weijg.fnst@cn.fujitsu.com> <1447827215.8767.3.camel@localhost> <564C48D9.8060507@samsung.com> In-Reply-To: <564C48D9.8060507@samsung.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.167.226.50] Content-Type: text/plain; charset="utf-8" Content-ID: <6FFB1020CE8ADD4295129E3A6C62289F@fujitsu.local> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tAJ9Ufaf024455 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 > > 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 > >> --- > >> 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; > > > {.n++%ݶw{.n+{G{ayʇڙ,jfhz_(階ݢj"mG?&~iOzv^m ?I