Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp266155ybk; Tue, 12 May 2020 22:48:31 -0700 (PDT) X-Google-Smtp-Source: APiQypKUyd2YyNY1sGnyhxDVNW3buYWEG+HGwrrj8nx+00fqxfCnLysLet6NIExl3owBn/Aj8iG4 X-Received: by 2002:a50:ea87:: with SMTP id d7mr19905781edo.48.1589348911548; Tue, 12 May 2020 22:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589348911; cv=none; d=google.com; s=arc-20160816; b=IwIzeL0DiC3wYLtFlSl7id62qyXQdq77YzWg9AdIR8A3vqTMQ7J05vK9z/7i0f0X1X 9Sg3kqI9bLja5nYz5nJkrPrZKjFvAuGWDJKgD4dZHepZG0uHCoHTLKMZ9eWVOO4ZvEFS HrPB4uexk1drRarjRgVk9lVnwJvRopbUbhBAN+iBvcpxlxWRHaCHOo6UN+FFUcY17tbN MrrhqzikqGojjh/QOWqpagYfbSrV3sFeO9Z95kQSJ3l19/6NychsyeGHJFbctrR0VpPd 4mMUkGSVMNmZV277CVWskc//+aqBMUlukOyEt4EQjEGPQO95JRGZgbi+j90dDu57e1go ykww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mKP+hdVfnxx8CT5+DMNLCUev81BrL1aoInU/pGi5Jdg=; b=hWTyiESnJl17uewv4K5tg1ghgKnH/K4UuQNousXCLyDd6zndBboil2tC2m/M6NHDFT mwJ+ZsjdzGG49skoAdN3DC4uISHFyXj1ETb9Pka/hzj7R1fGgXOzKkAdr7GzHTJEs2SX csfikviuDFVmIQOcZUNxCavIli1ijdCja0NkJTVffvbQ3A1lmGfM3NJ90HD9fEPpMVPO iPyIyL69DZW0Ev/YPY2BlVgpJ40jhuXhWGfAim5s0lVk6fu32ah2puS4d/4n1rPIozIM 20r6ExntMJPoEz+js2TaX9IXygaUAJJP4S6QLvoNP0J5ycjLxiGO/Ew41Jh6Hu4eHkY6 Cv8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi13si9554922edb.449.2020.05.12.22.48.08; Tue, 12 May 2020 22:48:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728865AbgEMFqS (ORCPT + 99 others); Wed, 13 May 2020 01:46:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728131AbgEMFqS (ORCPT ); Wed, 13 May 2020 01:46:18 -0400 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD9FC061A0C; Tue, 12 May 2020 22:46:18 -0700 (PDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jYkDZ-007EO7-Jb; Wed, 13 May 2020 05:46:09 +0000 Date: Wed, 13 May 2020 06:46:09 +0100 From: Al Viro To: Shuah Khan Cc: axboe@kernel.dk, zohar@linux.vnet.ibm.com, mcgrof@kernel.org, keescook@chromium.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2] fs: avoid fdput() after failed fdget() in ksys_sync_file_range() Message-ID: <20200513054609.GS23230@ZenIV.linux.org.uk> References: <71cc3966f60f884924f9dff8875ed478e858dca1.1589311577.git.skhan@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <71cc3966f60f884924f9dff8875ed478e858dca1.1589311577.git.skhan@linuxfoundation.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 01:43:04PM -0600, Shuah Khan wrote: > @@ -364,15 +364,15 @@ int sync_file_range(struct file *file, loff_t offset, loff_t nbytes, > int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes, > unsigned int flags) > { > - int ret; > - struct fd f; > + int ret = -EBADF; > + struct fd f = fdget(fd); > > - ret = -EBADF; > - f = fdget(fd); > - if (f.file) > - ret = sync_file_range(f.file, offset, nbytes, flags); > + if (!f.file) > + goto out; > > + ret = sync_file_range(f.file, offset, nbytes, flags); > fdput(f); > +out: > return ret; IDGI... What's the point of that goto out, when it leads straight to return?