From patchwork Fri Dec 14 19:50:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 10731607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0CEB213BF for ; Fri, 14 Dec 2018 19:50:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CFD92DAB3 for ; Fri, 14 Dec 2018 19:50:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01CF32DAD7; Fri, 14 Dec 2018 19:50:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E81F2DAA2 for ; Fri, 14 Dec 2018 19:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730566AbeLNTuU (ORCPT ); Fri, 14 Dec 2018 14:50:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:52796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730123AbeLNTuU (ORCPT ); Fri, 14 Dec 2018 14:50:20 -0500 Received: from localhost.localdomain (bl8-197-74.dsl.telepac.pt [85.241.197.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A03122080F for ; Fri, 14 Dec 2018 19:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544817021; bh=ctV5TY61Ai2F1w0R0ImuJg9axVRoYYjyc0bqNL2rNtc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=V8UspAV7/63jO5JLI2l5hWJpxwNPEnQDbPUmZh6vN0lwFwhZH2FeHAY1RXMe4jN4L HLgmAHzJhBinbTPw0uxnWmpsYSlqGN1zXmRDgUZKpTPXkOpM3NYaXYgMUjPTlZUCS7 o9Hh8doNQaUwJYab2eJMpFEKiyWv3jNEADKXEcT8= From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2] Btrfs: do not overwrite scrub error with fault error in scrub ioctl Date: Fri, 14 Dec 2018 19:50:17 +0000 Message-Id: <20181214195017.17822-1-fdmanana@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181214194459.21691-1-fdmanana@kernel.org> References: <20181214194459.21691-1-fdmanana@kernel.org> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Filipe Manana If scrub returned an error and then the copy_to_user() call did not succeed, we would overwrite the error returned by scrub with -EFAULT. Fix that by removing the call to copy_to_user() as there is no need to do it at all. Signed-off-by: Filipe Manana Reviewed-by: David Sterba --- V2: Leave to copy_to_user() call since progress needs to be reported back to user space. fs/btrfs/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 3a27efa2b955..4c05d9c4fe3d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4301,7 +4301,7 @@ static long btrfs_ioctl_scrub(struct file *file, void __user *arg) &sa->progress, sa->flags & BTRFS_SCRUB_READONLY, 0); - if (copy_to_user(arg, sa, sizeof(*sa))) + if (ret == 0 && copy_to_user(arg, sa, sizeof(*sa))) ret = -EFAULT; if (!(sa->flags & BTRFS_SCRUB_READONLY))