Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7276909imu; Wed, 14 Nov 2018 14:43:05 -0800 (PST) X-Google-Smtp-Source: AJdET5fF2v5Xo/cdX+4oIBYOHmmLsn6lnQm/CHXYU1oGAy1EpnXlrpqFuLnA6ge0nC0MW47A/aI7 X-Received: by 2002:a17:902:e005:: with SMTP id ca5-v6mr3652117plb.195.1542235385491; Wed, 14 Nov 2018 14:43:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542235385; cv=none; d=google.com; s=arc-20160816; b=erWwGuJHboJM5dNSAvz3zlLsfzbmuLIaqwmH+eGMSl1cpV6Vnl3ZcWCAqwhWD8cv6G 4oNoF5I3+AKByzjRmrX7T/6UEz0Kj12fPxK58ulqhF4I9nqEE5jhdYc5vUW+TqCJUHC+ mjaltKkQXY8XxQnXFIoUSzvh8BT+cynawroC+X8zfwRboIjZqNo+0h+5bDCcPjzJVxKa 9dRTHzMCjsxtWkXi+Xaw5qbNf+HY8jeUn6IV83aUQdJ1eRPVyY7oTUzvudAYYa6fv9kN kaMS/49gzrMkOVZBQyF7g+fQVSagjxu0yvatCSDW6BYG8wfWtwmYSLouI/va6e7pKu6E cnAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GeXMFfX3wu+zPspAslbUOdEVoMvMz6D7PiW7+zJ2uy0=; b=enPPyf2+f3crYTMyaLeNJi+cm8/FyCUKt7sE5PKR1BBEFtuwen6kMLVioJBk176AZJ lQ8GHf+QJWn826zvBEeeQjEYBQ7ABZxEcsK/xQRIgAlHzD7yEXcZ94BYj1kA1iKoQcmf 8NS94h56WELtRvLF1jo/Re0S+RYQMExZE8tj7UHlOgmWTS6cul74M0aJ7x0ryaZUTmXs f3oHcn+kNpow0P8H65SeD35p6FzPLskW4ft0q/9dx1Fc1CWB7dNOs7rez0F8AYzHgMh8 w4YgAP+2vLuSrTH+hX+YdYFpCNOSoYx6LPT8iLGWirbu/utaWY9zl/8RDRiDRjdf89GK BPXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PMpyZJtQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 88-v6si26385863plb.57.2018.11.14.14.42.51; Wed, 14 Nov 2018 14:43:05 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=PMpyZJtQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387652AbeKOIrY (ORCPT + 99 others); Thu, 15 Nov 2018 03:47:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:34716 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbeKOI1W (ORCPT ); Thu, 15 Nov 2018 03:27:22 -0500 Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (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 D95082252A; Wed, 14 Nov 2018 22:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542234138; bh=1LpCHfmrvSasWtRLwoH0j+BZ/0fFXfEt7fQM2byFWYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PMpyZJtQeJlPZ5FJzXDlK52JVHJRWYf4CG10w5ZzdxebmCKkGYy8FH8PExhrW0ilq uu3pO9/EYHvvK57tkoHzdkrMxaVrqWTaoj6uXW7zVQ8rWliG4+24UK3VhToQRzEzDD dyASmcDS5iaHFylgQdyfzEvGmrxTUj6KQzWy9oLY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Luis Henriques , Ilya Dryomov , Sasha Levin Subject: [PATCH AUTOSEL 4.19 45/73] ceph: quota: fix null pointer dereference in quota check Date: Wed, 14 Nov 2018 17:21:39 -0500 Message-Id: <20181114222207.98701-45-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181114222207.98701-1-sashal@kernel.org> References: <20181114222207.98701-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Luis Henriques [ Upstream commit 71f2cc64d027d712f29bf8d09d3e123302d5f245 ] This patch fixes a possible null pointer dereference in check_quota_exceeded, detected by the static checker smatch, with the following warning:    fs/ceph/quota.c:240 check_quota_exceeded()     error: we previously assumed 'realm' could be null (see line 188) Fixes: b7a2921765cf ("ceph: quota: support for ceph.quota.max_files") Reported-by: Dan Carpenter Signed-off-by: Luis Henriques Reviewed-by: "Yan, Zheng" Signed-off-by: Ilya Dryomov Signed-off-by: Sasha Levin --- fs/ceph/quota.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c index 32d4f13784ba..03f4d24db8fe 100644 --- a/fs/ceph/quota.c +++ b/fs/ceph/quota.c @@ -237,7 +237,8 @@ static bool check_quota_exceeded(struct inode *inode, enum quota_check_op op, ceph_put_snap_realm(mdsc, realm); realm = next; } - ceph_put_snap_realm(mdsc, realm); + if (realm) + ceph_put_snap_realm(mdsc, realm); up_read(&mdsc->snap_rwsem); return exceeded; -- 2.17.1