Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp853120pxk; Thu, 17 Sep 2020 19:07:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt4TS2LwKBpmnjHkqYd/n8Pf0FqPy4t0u+HGfqyBeisRIyh21Blkk5UFNzg+WhejV9Kaok X-Received: by 2002:a17:906:9491:: with SMTP id t17mr34963763ejx.253.1600394862796; Thu, 17 Sep 2020 19:07:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394862; cv=none; d=google.com; s=arc-20160816; b=DLKLY9HA2hHJ6IA7w8fzORCLVNJUp5vFzgv3I9YhuvC2nbqOyUG3qohIfT1iV9gp9O zc7TY0sAdOYNDL5aTcaUWCYrzpchpM9RIAaHcHv3vngX5gTPp1DdUAKIm5w58+F5DACH M33JRY9kOSXuHkx00pAEyYUydC3FQCtB3GbsXFsmr3bKffEGcM925ZsaojtgsguB5U0y zaRBjF2i38HnXy8azsR0x4Loe4CpCKh6zFEZFRvopdu+I8Vgw4atOBn5OFqIsX/PBYY7 lvaOBJYF7iBxjUVcmwOEILRMJWg6E2ukwvB4KrLauA/PzfJ0s/xX3gywGynljRbEKXnf 73Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IFWPrQC8BT8G/qzq5WL2CKpTdGu7flKrzO0k81ZIT0I=; b=Qfjnke8tVzj33CEx6d9dBd4XUDuxMUry/IdCD9GL/KAUIWf8mk0+WZx1IAZhYbgebi 8oiR/hTRzXvSa1nXJFbsJx4TnisLfnxXB+JhQ9NESGL/qZRGiJyD7MN3bJPAgqJVyK4S 99AtKSQCB11QofNkYibkhdCAok+tiB4Di7gW1WgNK6jsVYZKWrpbYo00rhtRwvsE804l TcIlGl8CONtiRDkAH5+Qq7Hx8veYDuh2Tg3K2allZ0pvqAnNSzE4YPZUnJu+O4RWVW8Q bT1CJO4EdWOmKtn+QagUnbM/mUbtLKxc4zMeuRhl5B4LpmyYqpHdfdjXo4TqbNW9R88M tTDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tJlDyPsY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si1048110edm.349.2020.09.17.19.07.19; Thu, 17 Sep 2020 19:07:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tJlDyPsY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbgIRCDZ (ORCPT + 99 others); Thu, 17 Sep 2020 22:03:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:49494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbgIRCDV (ORCPT ); Thu, 17 Sep 2020 22:03:21 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 5ACEF22211; Fri, 18 Sep 2020 02:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394601; bh=C/vWB/HWvbBoRq5OnbqfMnbsQfBPae8evloq2/dctHY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tJlDyPsY9EwGWOqvSKU0xkrEEcp1kNJqQxJWG3McESt4FwV8QG+NGNeZ+Fvhbvf74 mcaQ0eCibnkT4kmCG+cpIT975yrHF8ZrmAqoro14o3yv40in6/72eVcLvcLqFzUTH3 gbs9pEudcUTpXNw8Ie2BNut8PQ5UqZdFpA8ljPOI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jeff Layton , Ilya Dryomov , Sasha Levin , ceph-devel@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 108/330] ceph: ensure we have a new cap before continuing in fill_inode Date: Thu, 17 Sep 2020 21:57:28 -0400 Message-Id: <20200918020110.2063155-108-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeff Layton [ Upstream commit 9a6bed4fe0c8bf57785cbc4db9f86086cb9b193d ] If the caller passes in a NULL cap_reservation, and we can't allocate one then ensure that we fail gracefully. Signed-off-by: Jeff Layton Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index c07407586ce87..660a878e20ef2 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -754,8 +754,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page, info_caps = le32_to_cpu(info->cap.caps); /* prealloc new cap struct */ - if (info_caps && ceph_snap(inode) == CEPH_NOSNAP) + if (info_caps && ceph_snap(inode) == CEPH_NOSNAP) { new_cap = ceph_get_cap(mdsc, caps_reservation); + if (!new_cap) + return -ENOMEM; + } /* * prealloc xattr data, if it looks like we'll need it. only -- 2.25.1