Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3708993imm; Sun, 13 May 2018 18:33:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpiOYi3rSQokHviq++JUO2s2d7Y8drSOVVmViT9ybXbec65UmNEwQEeWe/0ITVx1CdSloGT X-Received: by 2002:a17:902:bb84:: with SMTP id m4-v6mr7554487pls.339.1526261602267; Sun, 13 May 2018 18:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526261602; cv=none; d=google.com; s=arc-20160816; b=mXTO4NaG4QZVtoW4NfnvUg0LE92gEMuWcl7FiC9+9K2DtvDqhSJL+/gVKqKNbBN3Mn zCk+sYWPS6V7ZtTUEZr0uUUB5PFJgmSd+NYpQ5EN9HHudOUKW3aDZQ0WZtHlQtiv22jl PLCrrnEFpGooFW79aboifB+jp17i66Aw7yjHinrlkGzj8dPGHrt9vIljYNmGFudkZ0ga g3mc86A/R0HifGi8B6Bo6bKgZwvnsBZruriNt35XpXzyNGwz9FUatoyR5cZKkWSV3ZtI IFsMXoVAr6O7+vdVeoErzMGe0P9OM0xxOW3EJH7jrp6xQfFipv9cjS02llf2P06QfiuJ pNTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=hSt+R0LDVWdqUiFEfnpHWGn3uZsGKPwAn9vjJHl+NSY=; b=kPVmaDi5yNc5bxA+/8QoM4quPQr3cKCQft3t9lwuEUgy+1LxI8bXekCutkIC4etLkU hrLENkjKH/wY6FyG3A1tWdIKzg25avki4mWBJ/P2FD3MHxptOcyuYoWwa2/SPC8GuDBi 41IPewhxRGeTJnT/hX9RMJj39NcAsXUVINJzcBWg0Z+IQHNzWiNE6tVt6H+5Kb3BCBv9 g7DKYLsx6wbZtBG02L4dYSIOjmaaTBPddj/eQUXuxApX8D28/FT2hLNsr90i4IwXBEin ltCVrx6aGn0ej018+eDdLEc0K6uxFPJ5EpqQZWHWYW5UpWBfrGk9a+R6jo4qRbwzi7a2 brrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail header.b=q8ZFBXqh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi10-v6si7749562plb.399.2018.05.13.18.33.07; Sun, 13 May 2018 18:33:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail header.b=q8ZFBXqh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alliedtelesis.co.nz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752022AbeENBcu (ORCPT + 99 others); Sun, 13 May 2018 21:32:50 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:37102 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbeENBcq (ORCPT ); Sun, 13 May 2018 21:32:46 -0400 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 267728364B; Mon, 14 May 2018 13:32:45 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1526261565; bh=hSt+R0LDVWdqUiFEfnpHWGn3uZsGKPwAn9vjJHl+NSY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=q8ZFBXqhAJa68+3WjBQF9oPH6Ej7ANQa80Nb+yLk0DgDsp/YZwf5HQKrmroDlSNvw BtzNdlT7RnEd+7yOXzIHHkg5nf2LZ0Zx1Mf3GQeF4CD8VYxGpkM6l9Kym1LP1dSvUP X0lEtRYCoYG8dFM+WqEY/zlJgNH8DsPNp0IYMgVE= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Mon, 14 May 2018 13:32:46 +1200 Received: from hamishm-dl.ws.atlnz.lc (hamishm-dl.ws.atlnz.lc [10.33.22.10]) by smtp (Postfix) with ESMTP id 5150613EDDC; Mon, 14 May 2018 13:32:46 +1200 (NZST) Received: by hamishm-dl.ws.atlnz.lc (Postfix, from userid 1133) id EFD1C54097A; Mon, 14 May 2018 13:32:44 +1200 (NZST) From: Hamish Martin To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Hamish Martin Subject: [PATCH v2 1/2] uio: Reduce return paths from uio_write() Date: Mon, 14 May 2018 13:32:22 +1200 Message-Id: <20180514013223.4828-2-hamish.martin@alliedtelesis.co.nz> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514013223.4828-1-hamish.martin@alliedtelesis.co.nz> References: <20180514013223.4828-1-hamish.martin@alliedtelesis.co.nz> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Drive all return paths for uio_write() through a single block at the end of the function. Signed-off-by: Hamish Martin Reviewed-by: Chris Packham --- v2: no changes drivers/uio/uio.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index fd4848392e0d..dd44df17004d 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -568,20 +568,29 @@ static ssize_t uio_write(struct file *filep, const char __user *buf, ssize_t retval; s32 irq_on; - if (!idev->info->irq) - return -EIO; + if (!idev->info->irq) { + retval = -EIO; + goto out; + } - if (count != sizeof(s32)) - return -EINVAL; + if (count != sizeof(s32)) { + retval = -EINVAL; + goto out; + } - if (!idev->info->irqcontrol) - return -ENOSYS; + if (!idev->info->irqcontrol) { + retval = -ENOSYS; + goto out; + } - if (copy_from_user(&irq_on, buf, count)) - return -EFAULT; + if (copy_from_user(&irq_on, buf, count)) { + retval = -EFAULT; + goto out; + } retval = idev->info->irqcontrol(idev->info, irq_on); +out: return retval ? retval : sizeof(s32); } -- 2.16.2