Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753612AbeAFPJb (ORCPT + 1 other); Sat, 6 Jan 2018 10:09:31 -0500 Received: from mout.web.de ([212.227.15.3]:55642 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753433AbeAFPJ3 (ORCPT ); Sat, 6 Jan 2018 10:09:29 -0500 Subject: [PATCH 2/5] mtd/rfd_ftl: Less function calls in scan_header() after error detection From: SF Markus Elfring To: linux-mtd@lists.infradead.org, Boris Brezillon , Brian Norris , Cyrille Pitchen , David Woodhouse , Marek Vasut , Richard Weinberger Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <6f10248e-d2c9-3c48-922c-be95ac5caba9@users.sourceforge.net> Date: Sat, 6 Jan 2018 16:08:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:3ll9OR9loEMTCwy0KCbPzQ+zMsDuBhNjgh1vK0E6bsv0JUJAbP1 wOU/S4PPpWYuKt9Q509/Tg3FROM1n5PSefHLSK0PDmVmhVCku7h5jYbNEA3M7Ghww9BZQ9o GRXXV91OPCcdHuI/5DmuQKIJ5xjfxTGtDO/Xlv9V8ePR0cTmkx+di8jpVbaxuDKTNs79Ygq 5KrWYu3KvNvUv5cMqSdCw== X-UI-Out-Filterresults: notjunk:1;V01:K0:UdliNnAmQCw=:BHQ3xNng9yE+m/n8CLwqW9 pEPPJPNvkXI3o8jBedyZMzl1taAlZIUST3GS0bjlro3ZKmtYWHxz9/Z+suLPzMxs95WKRuD4u tPAL4VxsQRQLUyuRZ5vYvoRWycfOhPmsGm0oWLsmGgmoZopC7jnB+dPcPnq4Gq7hukapSDl5D vxPsbxSqq+lynCXK+dbF+dNhwgswk56YCP3uYpwL7ONGD48mhQcRkGKMkwHLfCeMa4uvmDbQH Yo4V0V+D6vpPMZGKGHlVmlIgbKFDHgnWGTElozoRW0VkQd2PQudHELDtWOLDpHIwQCJINB4dX b/pEAHR94OVpwJJzaVUJ7muPga7TMyDy6XHd0FWirXH/aEy/IG+24/ErRAYhis2RJmA9MkugG 1Wp2g+1RCYAhQQyvH1pp96Yw7pQXXGQCujloL5Vhe5eYrABwferapXPUaeBJn0xH5WAfFWe3S FLNQ4pc0F3As+u0zLq3shw2I1GR4GZYqDi+mZZk/izVp/iXlIU9w3sRVS9skacfV9Xr1rMb7M urArqWumJHu+syn/5suef6JfEFY8KIji/mMftNoO5xO2wFuJMlyE3WbbLkpLC3GrZOb4LaKLM 1GWQjBIWf7Oa/lUlvWzbANgLh27u9s+Uf4ZHIsvn8dWN9rW5VA4RewG/SgMQBKYpiFa3aF2l6 l6dqkzjYlVw1TZUBSfLjSnJGlciPtGRSFO8ZCLoW3RHtSb3G1JDZYt9+nFMvEUcUgAwJg2/qD E29S3oCLmxq+JNIT1lt9BJod+aizy8Mq8DChsmMqNbdbRe1KQty8uNmGu91P+mI8WWCoxGr0h mDCWfoQKOntdPIjVBbbtVk/JeCzaNQePCqlZKz1zk8NdAtAhLQ= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Markus Elfring Date: Sat, 6 Jan 2018 14:50:58 +0100 The functions "kfree" and "vfree" were called in three cases by the scan_header() function during error handling even if the passed data structure member contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/mtd/rfd_ftl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index efff25f15d5b..19e14f909dc6 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c @@ -182,16 +182,16 @@ static int scan_header(struct partition *part) part->header_cache = kmalloc(part->header_size, GFP_KERNEL); if (!part->header_cache) - goto err; + return -ENOMEM; part->blocks = kcalloc(part->total_blocks, sizeof(struct block), GFP_KERNEL); if (!part->blocks) - goto err; + goto free_cache; part->sector_map = vmalloc(part->sector_count * sizeof(u_long)); if (!part->sector_map) - goto err; + goto free_blocks; for (i=0; isector_count; i++) part->sector_map[i] = -1; @@ -229,9 +229,10 @@ static int scan_header(struct partition *part) err: vfree(part->sector_map); - kfree(part->header_cache); +free_blocks: kfree(part->blocks); - +free_cache: + kfree(part->header_cache); return rc; } -- 2.15.1