Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp29689imm; Fri, 21 Sep 2018 17:25:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV62uXSswYnK9Rkx7eMW36Upv2a1Es8rg/d0nrcP3K5SbLRULCWXv7XXFiKkxJxl4mHe6zUFT X-Received: by 2002:a17:902:848d:: with SMTP id c13-v6mr129509plo.194.1537575950160; Fri, 21 Sep 2018 17:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575950; cv=none; d=google.com; s=arc-20160816; b=ZY3mszv5dCJRPKV2jH//Xj4zP1WQplt7GOzAYSRqJhu5To3GkChmw40H3JyrIGQTdL 8rya6plIe/NoIaIa2j6TlENxiTEDP+cbb42b6TGRthtKag7h7qaRwPZN1OCIEeEVJh1u MPOWNlr2GpUHTk1H1E4BMDytZfrUWwMSRnSS2rvE5zqUe9LfhQ1cE7NdBRQj2geOMTID oH7At4/4gOMW0UgTwjfkFCPjiTDYn9pqs0xU67RZhJKT6DMI7oXn24azGJG+G8DtZF9P h/GKxDox61Ia85FhPU4QLcZdOiK5mv2dRAQ4fVIbT/FuQrYdivnX68YCOcjltnQ8ngfx wPxA== 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:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=aQ6wiA8rw5n+/5Q4qHXUpKgWS6nJmUrVEIigrKBTrd4=; b=t6uyis7eZ28/CuaVtE0kwW6Tg5JlOVixbdTbnzp8ks+4S3ZYv7jCqk54sEFCpO3Mv6 LL0YRUKFQs3+uO7RWCOcj8NenRjIoma6WwQPnjOMhQZSWA2+U351wGsfBkm8HHDUWYzT GWbX5/7xkrWU/FcObkO4F/ML3nX/Am0M08SJ7mzWvcNncHxHofVU5+CPPMxLTk6qWWwb /iyK0/YnjC2kIoP+hPiA93+NxzHa8PMq1vmXDYyCcr7Mw2CeK7WlMDFE6+UXC8dhZ9ab YtJ+lj51qirdzZ3GdfzL/EnCJ76TYeLK5vBud/H65jYHKEMyNMBJtn5DV0Cwdr7sR5at p7ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e26-v6si4849616pgb.161.2018.09.21.17.25.34; Fri, 21 Sep 2018 17:25:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392094AbeIVGPf (ORCPT + 99 others); Sat, 22 Sep 2018 02:15:35 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44167 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391937AbeIVGKp (ORCPT ); Sat, 22 Sep 2018 02:10:45 -0400 Received: from [2a02:8011:400e:2:cbab:f00:c93f:614] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1g3Vdv-0008BS-5d; Sat, 22 Sep 2018 01:19:27 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdo-0000tx-Vr; Sat, 22 Sep 2018 01:19:20 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Eric Sandeen" , "Darrick J. Wong" , "Eric Sandeen" , "Xu, Wen" Date: Sat, 22 Sep 2018 01:15:42 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 53/63] xfs: don't call xfs_da_shrink_inode with NULL bp In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:cbab:f00:c93f:614 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.58-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eric Sandeen commit bb3d48dcf86a97dc25fe9fc2c11938e19cb4399a upstream. xfs_attr3_leaf_create may have errored out before instantiating a buffer, for example if the blkno is out of range. In that case there is no work to do to remove it, and in fact xfs_da_shrink_inode will lead to an oops if we try. This also seems to fix a flaw where the original error from xfs_attr3_leaf_create gets overwritten in the cleanup case, and it removes a pointless assignment to bp which isn't used after this. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199969 Reported-by: Xu, Wen Tested-by: Xu, Wen Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong [bwh: Backported to 3.16: adjust filename] Signed-off-by: Ben Hutchings --- fs/xfs/xfs_attr_leaf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c @@ -701,9 +701,8 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t ASSERT(blkno == 0); error = xfs_attr3_leaf_create(args, blkno, &bp); if (error) { - error = xfs_da_shrink_inode(args, 0, bp); - bp = NULL; - if (error) + /* xfs_attr3_leaf_create may not have instantiated a block */ + if (bp && (xfs_da_shrink_inode(args, 0, bp) != 0)) goto out; xfs_idata_realloc(dp, size, XFS_ATTR_FORK); /* try to put */ memcpy(ifp->if_u1.if_data, tmpbuffer, size); /* it back */