From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751504AbdKUPrI (ORCPT ); Tue, 21 Nov 2017 10:47:08 -0500 Received: from mailout.easymail.ca ([64.68.200.34]:44842 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750794AbdKUPrE (ORCPT ); Tue, 21 Nov 2017 10:47:04 -0500 Reply-To: shuah@kernel.org Subject: Re: [PATCH] selftest: sync: Use common error handling code in sync_file_info() To: SF Markus Elfring , linux-kselftest@vger.kernel.org, =?UTF-8?Q?Emilio_L=c3=b3pez?= Cc: LKML , kernel-janitors@vger.kernel.org, Shuah Khan , Shuah Khan References: <219c366b-d753-e65b-b021-6d4a584588d0@users.sourceforge.net> From: Shuah Khan Message-ID: <3a27095e-84ad-6e93-bae5-3b242a042238@kernel.org> Date: Tue, 21 Nov 2017 08:46:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <219c366b-d753-e65b-b021-6d4a584588d0@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/20/2017 02:25 PM, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 20 Nov 2017 22:20:37 +0100 > > Add a jump target so that a bit of exception handling can be better reused > at the end of this function. > > This issue was detected by using the Coccinelle software. I would like to see the Coccinelle log included in the commit log > > Signed-off-by: Markus Elfring > --- > tools/testing/selftests/sync/sync.c | 19 +++++++++---------- > 1 file changed, 9 insertions(+), 10 deletions(-) > > diff --git a/tools/testing/selftests/sync/sync.c b/tools/testing/selftests/sync/sync.c > index f3d599f249b9..d0d55377f6f8 100644 > --- a/tools/testing/selftests/sync/sync.c > +++ b/tools/testing/selftests/sync/sync.c > @@ -92,10 +92,8 @@ static struct sync_file_info *sync_file_info(int fd) > return NULL; > > err = ioctl(fd, SYNC_IOC_FILE_INFO, info); > - if (err < 0) { > - free(info); > - return NULL; > - } > + if (err < 0) > + goto free_info; > > num_fences = info->num_fences; > > @@ -104,22 +102,23 @@ static struct sync_file_info *sync_file_info(int fd) > info->num_fences = num_fences; > > fence_info = calloc(num_fences, sizeof(*fence_info)); > - if (!fence_info) { > - free(info); > - return NULL; > - } > + if (!fence_info) > + goto free_info; > > info->sync_fence_info = (uint64_t)fence_info; > > err = ioctl(fd, SYNC_IOC_FILE_INFO, info); > if (err < 0) { > free(fence_info); Why not add a free_fence_info to make it consistent? > - free(info); > - return NULL; > + goto free_info; > } > } > > return info; > + > +free_info: > + free(info); > + return NULL; > } > > static void sync_file_info_free(struct sync_file_info *info) > thanks, -- Shuah