Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp934968imw; Wed, 13 Jul 2022 10:34:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sWyfij7xK2rq5emrBOvT3fpA4gLgcAHtCKWUv8JXgEMO9ySKyannXr2c4W2LDWbANGHnSQ X-Received: by 2002:a17:907:7615:b0:72b:35a6:5992 with SMTP id jx21-20020a170907761500b0072b35a65992mr4471363ejc.97.1657733681229; Wed, 13 Jul 2022 10:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657733681; cv=none; d=google.com; s=arc-20160816; b=VnJIcubLrM56HLDOf9KyB/gBzqeKzm6KYfg/eggDLuyZyKkFpK/cmMOV+RTcZNV5dt VCghIRvS+ABCWhy6qdBgpZTJ7q+ymlYlh+TCPWvPxV+fysH5Vb5ZN2yCOqFWw44BKnm5 sbUqg1GFdNQnMszQM0Q+5sZlso9ITtP6V2SlluZ4NXhmZEH2isnWIEhm7Zhdx99rvocQ M23QNsYNJmvLm+R8EVBhhbAAJNFI0dhG9FiPqT71yi7iWfjVj/DjU0M5cqB4Sajbwbq4 F5uNfjvJBdKtESfhILiA6xGaGwb4GDWSgglRueQeJ1DkIqxDrgH7nYSGB6pcWxocrrhx Re1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=uzHNxd7dfVtO8sDJoVYoTuddxcGC53KhUNVKS77W3J0=; b=ua4S+O3TqHlC+DN7hIfPm9CVLheVrelHs4B8lR3SwIFr1zzVdimM+X+IgzxGtPlbV+ 88+txj+9yHk2KKJQvztddzeEgnhPhK7XlNabZ/7spQ9vJmtixxgKYC6VZz4uHIB5NrWB DGH69EHYsriMEQiNpUWwPOjIADvRgT1gkS2TPxR1GTo4jQUrxP+y3y3OmJvOC0zGf964 l/oTo9proQCPnmiuDl6rHHiPUadlFPS0cSmjL9e26GuX0DVbf/A6fBwncKLw2LUHmQnI vBVKhQxJ7F6hp5/3C7EP2j6mRnirOODfp/dqxo8MgVAMi6vYpWTLiB6F1YmxciyAyfgt 7C7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=YOonUpH+; dkim=pass header.i=@paragon-software.com header.s=mail header.b=NkfYVRoS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a05640240cf00b0043a837b7216si22162810edb.28.2022.07.13.10.34.10; Wed, 13 Jul 2022 10:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@paragon-software.com header.s=mail header.b=YOonUpH+; dkim=pass header.i=@paragon-software.com header.s=mail header.b=NkfYVRoS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=paragon-software.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236744AbiGMQr4 (ORCPT + 99 others); Wed, 13 Jul 2022 12:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236688AbiGMQrw (ORCPT ); Wed, 13 Jul 2022 12:47:52 -0400 Received: from relayaws-01.paragon-software.com (relayaws-01.paragon-software.com [35.157.23.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B312B2FFC0; Wed, 13 Jul 2022 09:47:51 -0700 (PDT) Received: from relayfre-01.paragon-software.com (unknown [172.30.72.12]) by relayaws-01.paragon-software.com (Postfix) with ESMTPS id 1161E1DDC; Wed, 13 Jul 2022 16:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1657730802; bh=uzHNxd7dfVtO8sDJoVYoTuddxcGC53KhUNVKS77W3J0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=YOonUpH+axxRMOO52aSRGsF3Zgb0BA3kAz89srY2VBWouNhoMhXET3hE8X7saCQIX YrnrZn16o0Sf5EbARTW0xIPJJ48J5bqGpEvB8yrR2fD1IkZzRfYoN82VH1L7BdpNuB 3KI6auNQ3g1YpoIbnxs6qhB9rNOXcGj21DoAfqio= Received: from dlg2.mail.paragon-software.com (vdlg-exch-02.paragon-software.com [172.30.1.105]) by relayfre-01.paragon-software.com (Postfix) with ESMTPS id 9316F213E; Wed, 13 Jul 2022 16:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paragon-software.com; s=mail; t=1657730869; bh=uzHNxd7dfVtO8sDJoVYoTuddxcGC53KhUNVKS77W3J0=; h=Date:Subject:From:To:CC:References:In-Reply-To; b=NkfYVRoSUZ+PooFsLHSf3tCEG1YmZ76zWJBU7PTyUzLtRkQgYIhcAZg+4L7sEC/hG Cv7Y2/RaJDCk0UOSlLuWWXN8mwRcECpH1UDmwKRWpWCfmKR/TsAnmvau0DCStP/W/w Q4VoF/VpmSd8d0HNXB7pzwn0mGTB0Fo1ns7uqqSw= Received: from [172.30.8.65] (172.30.8.65) by vdlg-exch-02.paragon-software.com (172.30.1.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.7; Wed, 13 Jul 2022 19:47:49 +0300 Message-ID: <8a2f659b-a73c-349d-5bf2-506b9084a28d@paragon-software.com> Date: Wed, 13 Jul 2022 19:47:48 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: [PATCH 6/6] fs/ntfs3: Make ni_ins_new_attr return error Content-Language: en-US From: Konstantin Komarov To: CC: , References: <2101d95b-be41-6e6d-e019-bc70f816b2e8@paragon-software.com> In-Reply-To: <2101d95b-be41-6e6d-e019-bc70f816b2e8@paragon-software.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [172.30.8.65] X-ClientProxiedBy: vdlg-exch-02.paragon-software.com (172.30.1.105) To vdlg-exch-02.paragon-software.com (172.30.1.105) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function ni_ins_new_attr now returns ERR_PTR(err), so we check it now in other functions like ni_expand_mft_list Signed-off-by: Konstantin Komarov --- fs/ntfs3/frecord.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index bdc568053fae..381a38a06ec2 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -469,7 +469,7 @@ ni_ins_new_attr(struct ntfs_inode *ni, struct mft_inode *mi, &ref, &le); if (err) { /* No memory or no space. */ - return NULL; + return ERR_PTR(err); } le_added = true; @@ -1011,6 +1011,8 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le, name_off, svcn, ins_le); if (!attr) continue; + if (IS_ERR(attr)) + return PTR_ERR(attr); if (ins_attr) *ins_attr = attr; @@ -1032,8 +1034,15 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le, attr = ni_ins_new_attr(ni, mi, le, type, name, name_len, asize, name_off, svcn, ins_le); - if (!attr) + if (!attr) { + err = -EINVAL; goto out2; + } + + if (IS_ERR(attr)) { + err = PTR_ERR(attr); + goto out2; + } if (ins_attr) *ins_attr = attr; @@ -1045,7 +1054,6 @@ static int ni_ins_attr_ext(struct ntfs_inode *ni, struct ATTR_LIST_ENTRY *le, out2: ni_remove_mi(ni, mi); mi_put(mi); - err = -EINVAL; out1: ntfs_mark_rec_free(sbi, rno, is_mft); @@ -1101,6 +1109,11 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, if (asize <= free) { attr = ni_ins_new_attr(ni, &ni->mi, NULL, type, name, name_len, asize, name_off, svcn, ins_le); + if (IS_ERR(attr)) { + err = PTR_ERR(attr); + goto out; + } + if (attr) { if (ins_attr) *ins_attr = attr; @@ -1198,6 +1211,11 @@ static int ni_insert_attr(struct ntfs_inode *ni, enum ATTR_TYPE type, goto out; } + if (IS_ERR(attr)) { + err = PTR_ERR(attr); + goto out; + } + if (ins_attr) *ins_attr = attr; if (ins_mi) @@ -1313,6 +1331,11 @@ static int ni_expand_mft_list(struct ntfs_inode *ni) goto out; } + if (IS_ERR(attr)) { + err = PTR_ERR(attr); + goto out; + } + attr->non_res = 1; attr->name_off = SIZEOF_NONRESIDENT_LE; attr->flags = 0; -- 2.37.0