Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp184556imm; Thu, 10 May 2018 18:15:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqloWzBflK4PsXsQ+fmUpovWSa9/2WxN9few9pw6EA+JfJ+3wjyN2KnyLAltGRtKskque7f X-Received: by 2002:a17:902:ab93:: with SMTP id f19-v6mr3494679plr.392.1526001312412; Thu, 10 May 2018 18:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526001312; cv=none; d=google.com; s=arc-20160816; b=o76HY3rj7LfChztMvEX7auwBqY0UyAvb+p6DLPS3JwiTj+v09Cp/DD46HShN6QPwSX z+HTUfJMj6z2BpsVwDG9EOWFXnkhziRmsPAYUpuY+8gwg4j4pZBQjtKQODDcnRmIGCb/ XsygYYHq+QYkOlWxg2OPNuZestr+MFY/1H7lCBA1loA6BxVmxkzcKIC/MZwAP14W9Oa9 OPW/40LEm3OTpVluMYXoDfDsJBRHNNaTIMwxr2Ew1MFSm5M1tfg5C/LS8zcOzODUVzR3 2V14kQxMFR1U4EQnRbYu5aRud1tBlcModikiKPJtcRwACYfoGSoCS69VCIDqaFZajMRQ syGw== 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=YQTqS1dTC6hImCsKxogh+29SDHat3bb7bb5KVdD0+iQ=; b=iLn30Ie2g79HOdb1asoZDDeNN/ll9gWnNNnDgmPz7vkffxCoiWYpJfg7dYU1QaDVXf eHmupzV3g2myaHdwxE6LboZGdyhiV/SLWgvTPlGANF0l0vDOEPhEHsx8+iogXhDWA3SU viwE1ZfKemWMrdCTnzDUUSOo0p/zmEFVCb0ymlmabkT1jhjL8vkYWfYJHlSoZ2pF0leq i2KttFiuy6jZ9o5LwmbKRCRymSdh2OdkVVrUP1GIg6/16iOYI8VHGXtMUsUTls8K74Cl myDD4LxY2Wr3Iz6uB72YJiUSBJiGmdA11BcFhymzHQWqRsLQRuW+Upj0ZXjmJ4Ydl3Dx ATTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alliedtelesis.co.nz header.s=mail header.b=iNuD+2pZ; 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 b11-v6si1539523pgt.629.2018.05.10.18.14.57; Thu, 10 May 2018 18:15:12 -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=iNuD+2pZ; 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 S1751981AbeEKBN4 (ORCPT + 99 others); Thu, 10 May 2018 21:13:56 -0400 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:33527 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751856AbeEKBNz (ORCPT ); Thu, 10 May 2018 21:13:55 -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 CA46B806B7; Fri, 11 May 2018 13:13:53 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1526001233; bh=YQTqS1dTC6hImCsKxogh+29SDHat3bb7bb5KVdD0+iQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iNuD+2pZGGP3Yet8AnqOfnFnQDONE+a7l5rbzzDRccG5OFmX6aH37io8tFOPtzuQv 4b8slT3/T+a7RYu6RiQtS3knXPOByqf57t2wK5/qMt5XWesZa6KJ8RgWZpQ5kAyXLx rYXk5oKQ0tzR3sTrPTGOU2oyC3y7hq1rkTvk1ar8= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 11 May 2018 13:11:22 +1200 Received: from hamishm-dl.ws.atlnz.lc (hamishm-dl.ws.atlnz.lc [10.33.22.10]) by smtp (Postfix) with ESMTP id E37DE13EEAA; Fri, 11 May 2018 13:11:18 +1200 (NZST) Received: by hamishm-dl.ws.atlnz.lc (Postfix, from userid 1133) id AD66A546F53; Fri, 11 May 2018 13:11:17 +1200 (NZST) From: Hamish Martin To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Hamish Martin Subject: [PATCH 1/2] uio: Reduce return paths from uio_write() Date: Fri, 11 May 2018 13:11:04 +1200 Message-Id: <20180511011105.12193-2-hamish.martin@alliedtelesis.co.nz> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180511011105.12193-1-hamish.martin@alliedtelesis.co.nz> References: <20180511011105.12193-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 --- 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