From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BACECC43387 for ; Mon, 14 Jan 2019 16:49:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 91B1C206B7 for ; Mon, 14 Jan 2019 16:49:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726747AbfANQtD (ORCPT ); Mon, 14 Jan 2019 11:49:03 -0500 Received: from verein.lst.de ([213.95.11.211]:47708 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbfANQtD (ORCPT ); Mon, 14 Jan 2019 11:49:03 -0500 Received: by newverein.lst.de (Postfix, from userid 2407) id 235C768D93; Mon, 14 Jan 2019 17:49:02 +0100 (CET) Date: Mon, 14 Jan 2019 17:49:02 +0100 From: Christoph Hellwig To: Carlos Maiolino Cc: linux-fsdevel@vger.kernel.org, hch@lst.de, adilger@dilger.ca, sandeen@redhat.com, david@fromorbit.com Subject: Re: [PATCH 04/10 V2] fibmap: Use bmap instead of ->bmap method in ioctl_fibmap Message-ID: <20190114164902.GA7187@lst.de> References: <20181205091728.29903-1-cmaiolino@redhat.com> <20181205091728.29903-5-cmaiolino@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181205091728.29903-5-cmaiolino@redhat.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Dec 05, 2018 at 10:17:22AM +0100, Carlos Maiolino wrote: > Now we have the possibility of proper error return in bmap, use bmap() > function in ioctl_fibmap() instead of calling ->bmap method directly. > > V2: > - Use a local sector_t variable to asign the block number > instead of using direct casting. > > Signed-off-by: Carlos Maiolino > --- > fs/ioctl.c | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > > diff --git a/fs/ioctl.c b/fs/ioctl.c > index d64f622cac8b..e0cc0dd5f9aa 100644 > --- a/fs/ioctl.c > +++ b/fs/ioctl.c > @@ -53,19 +53,26 @@ EXPORT_SYMBOL(vfs_ioctl); > > static int ioctl_fibmap(struct file *filp, int __user *p) > { > + struct inode *inode = file_inode(filp); > + int error, usr_blk; > + sector_t block; > > if (!capable(CAP_SYS_RAWIO)) > return -EPERM; > + > + error = get_user(usr_blk, p); > + if (error) > + return error; Does get_user/put_user actually return an error? All the code I know just does: if (get_user())) return -EFAULT; and co. > + > + block = usr_blk; > + error = bmap(inode, &block); > + if (error) > + return error; > + usr_blk = block; Nitpick: maybe i'd name ur_block block and block sector, which seems to flow a little better.