From patchwork Mon Aug 21 11:55:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9912343 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0FB59602D8 for ; Mon, 21 Aug 2017 11:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED2DD27FA8 for ; Mon, 21 Aug 2017 11:56:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2128286E4; Mon, 21 Aug 2017 11:56:32 +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=-6.9 required=2.0 tests=BAYES_00,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 705F627FA8 for ; Mon, 21 Aug 2017 11:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753773AbdHUL4Y (ORCPT ); Mon, 21 Aug 2017 07:56:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:32879 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753538AbdHULzW (ORCPT ); Mon, 21 Aug 2017 07:55:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A6581ACBF; Mon, 21 Aug 2017 11:55:19 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id EB99C1E3475; Mon, 21 Aug 2017 13:55:18 +0200 (CEST) From: Jan Kara To: Cc: Wang Shilong , Andreas Dilger , Jan Kara Subject: [PATCH 15/27] quota: Fix error codes in v2_read_file_info() Date: Mon, 21 Aug 2017 13:55:05 +0200 Message-Id: <20170821115517.26542-16-jack@suse.cz> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20170821115517.26542-1-jack@suse.cz> References: <20170821115517.26542-1-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP v2_read_file_info() returned -1 instead of proper error codes on error. Luckily this is not easily visible from userspace as we have called ->check_quota_file shortly before and thus already verified the quota file is sane. Still set the error codes to proper values. Reviewed-by: Andreas Dilger Signed-off-by: Jan Kara --- fs/quota/quota_v2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c index 373d7cfea5b0..21a8bdf7cfec 100644 --- a/fs/quota/quota_v2.c +++ b/fs/quota/quota_v2.c @@ -99,13 +99,13 @@ static int v2_read_file_info(struct super_block *sb, int type) down_read(&dqopt->dqio_sem); if (!v2_read_header(sb, type, &dqhead)) { - ret = -1; + ret = -EIO; goto out; } version = le32_to_cpu(dqhead.dqh_version); if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) || (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1)) { - ret = -1; + ret = -EINVAL; goto out; } @@ -113,7 +113,7 @@ static int v2_read_file_info(struct super_block *sb, int type) sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); if (size != sizeof(struct v2_disk_dqinfo)) { quota_error(sb, "Can't read info structure"); - ret = -1; + ret = -EIO; goto out; } info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS);