From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.web.de (mout.web.de [212.227.15.14]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3v49CZ6KsRzDqWX for ; Fri, 20 Jan 2017 04:03:38 +1100 (AEDT) Subject: [PATCH 4/8] powerpc/nvram: Return directly after a failed parameter validation in dev_nvram_read() To: linuxppc-dev@lists.ozlabs.org, Benjamin Herrenschmidt , Daniel Axtens , Geliang Tang , Michael Ellerman , Nathan Fontenot , Pan Xinhui , Paul Gortmaker , Paul Mackerras References: <53545d97-6ed5-ff17-384f-82e72b3592f9@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Thu, 19 Jan 2017 17:57:37 +0100 MIME-Version: 1.0 In-Reply-To: <53545d97-6ed5-ff17-384f-82e72b3592f9@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Markus Elfring Date: Thu, 19 Jan 2017 16:12:48 +0100 * Return directly after an inappropriate input parameter was detected. * Delete an initialisation for the variable "tmp" at the beginning which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- arch/powerpc/kernel/nvram_64.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c index dc90a0e9ad65..463551589b97 100644 --- a/arch/powerpc/kernel/nvram_64.c +++ b/arch/powerpc/kernel/nvram_64.c @@ -745,24 +745,18 @@ static ssize_t dev_nvram_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { ssize_t ret; - char *tmp = NULL; + char *tmp; ssize_t size; - if (!ppc_md.nvram_size) { - ret = -ENODEV; - goto out; - } + if (!ppc_md.nvram_size) + return -ENODEV; size = ppc_md.nvram_size(); - if (size < 0) { - ret = size; - goto out; - } + if (size < 0) + return size; - if (*ppos >= size) { - ret = 0; - goto out; - } + if (*ppos >= size) + return 0; count = min_t(size_t, count, size - *ppos); count = min(count, PAGE_SIZE); -- 2.11.0