From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755513AbbKRJqI (ORCPT ); Wed, 18 Nov 2015 04:46:08 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:40381 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755115AbbKRJqF (ORCPT ); Wed, 18 Nov 2015 04:46:05 -0500 MIME-version: 1.0 Content-type: text/plain; charset=utf-8 X-AuditID: cbfec7f5-f79b16d000005389-1f-564c48daed87 Content-transfer-encoding: 8BIT Subject: Re: [PATCH] tools: ffs-aio-example: free memory upon failure To: "Wei, Jiangang" , "standby24x7@gmail.com" References: <1447049776-23413-1-git-send-email-weijg.fnst@cn.fujitsu.com> <1447827215.8767.3.camel@localhost> Cc: "rdunlap@infradead.org" , "linux-kernel@vger.kernel.org" , "balbi@ti.com" , "jkosina@suse.cz" From: Robert Baldyga Message-id: <564C48D9.8060507@samsung.com> Date: Wed, 18 Nov 2015 10:46:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-reply-to: <1447827215.8767.3.camel@localhost> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRmVeSWpSXmKPExsVy+t/xa7q3PHzCDHYcULc4eL/eYvecxSwW l3fNYbN4e2c6i8WlGdfZLZrvBTqwefw/OInZY+esu+wem1doeZxZcITd4/iN7UwenzfJBbBF cdmkpOZklqUW6dslcGUsmtHHWvBNrOL673vMDYzrhboYOTkkBEwkfm84xw5hi0lcuLeerYuR i0NIYCmjxMRlC1hAErwCghI/Jt8Dsjk4mAXkJY5cyoYw1SWmTMkFqRASeMYosWC2A4gtLOAq sepqK9hIEYEkiaaVJ9ggavIlrryazAQynllgF6PEr3NNYAk2AR2JLd8nMEKs0pJ4NmsCK4jN IqAq0fH8EhOILSoQITFxQgNYnFPAQOLYyk3sExgFZiG5bhbCdbMQrlvAyLyKUTS1NLmgOCk9 10ivODG3uDQvXS85P3cTIySwv+5gXHrM6hCjAAejEg9v4mLvMCHWxLLiytxDjBIczEoivO91 fcKEeFMSK6tSi/Lji0pzUosPMUpzsCiJ887c9T5ESCA9sSQ1OzW1ILUIJsvEwSnVwNhae8vf hKVCYuutS3vW/85cdu71QY/bLfea/preN7r1a4GjG2ck6/JqE8moZYd7bp8Iag5LW1IxfYX7 Jee7zzmn5s90eN9qoZ3c4rO0rK72+ccbiWFSXtLiDn4i/57O521U7Hng9XYl92SLn/OKfv+f G1HRuD7Egz2uqOyJj+uND48FpEu2SSmxFGckGmoxFxUnAgAeiU6caAIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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; >