Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp412058imu; Mon, 5 Nov 2018 03:01:37 -0800 (PST) X-Google-Smtp-Source: AJdET5eQiV8BohwCJ8sPOUy9dmzCwZgIlYEXFSx0N4sFeJZaZb77sfu8gJDX4+i28RnM4ygm3avJ X-Received: by 2002:a63:f74f:: with SMTP id f15mr19897437pgk.190.1541415697005; Mon, 05 Nov 2018 03:01:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541415696; cv=none; d=google.com; s=arc-20160816; b=a5CfUFy4ZdLcPfqt1epdChQAs3KOGppha6Rv33rJWlD41vPjshpfz0L1jUQfw8p+aY OsvsILc0T7alNfV4rQYIfMbbu+HxngnLf58y1w6/JCNdx2rxKrQudUkmZ14ODmei44xJ YRefAP5mVyQZ7OJxJ9T8z5wN0aNJiR8M4i3So8SgN4AiOf/LhM2yJgG1Ymz56O0U4Na8 yuxLr6geo9J9wVrjNajSJGKPm8z1rKuatlMm2RBxqTX6rVG0bFvj34KcqkiMMxOp44V9 eBB54KwhdF36mVEnj8aspjON/8f+OdHgu9ydKMwoPeZ/7Vc0V9POUt3gvbXaq4lbHqVO yHfA== 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; bh=IbuBupMUIG9EQHK0QDYcpOAzfs9OiF63eN0vme3QjZM=; b=pdtpZ50/zLJ5uILC/9VQdejgEBIGjgPJ/bM6Z2ZUjQVSwI5zr5kMa4y1JyYGK2y7wm Rz076x+6lK01fd1vRxZgplI3Aa7rKOXlO6eubPcuy+cz2I+zC4euRfSj5N72cUmCKnu8 lx92mV6zRQ4Q7Iroy5/GPjDg7HdeoazNJYIo5pE3EFMBCaUP6OeALZzESm0pSUgaiFra MegfbWKk6CNC9inrwbd3eOQ1k7WwhyUJIWlgYwv8xfXpfScFlX2+hylqarVKU/WGbxy6 002+qyPpc9miqNdIkxjwzGov07mbcyl5M0fkHFXfw9XPfe3rKRt592G877sU6WwC7DjX OVig== 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 z70-v6si16816495pfi.165.2018.11.05.03.01.22; Mon, 05 Nov 2018 03:01:36 -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; 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 S1729086AbeKEUUB (ORCPT + 99 others); Mon, 5 Nov 2018 15:20:01 -0500 Received: from mx2.suse.de ([195.135.220.15]:51004 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727275AbeKEUUB (ORCPT ); Mon, 5 Nov 2018 15:20:01 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 33FB2AF8D; Mon, 5 Nov 2018 11:00:51 +0000 (UTC) From: Luis Henriques To: "Yan, Zheng" , Sage Weil , Ilya Dryomov Cc: Dan Carpenter , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Henriques Subject: [PATCH] ceph: quota: fix null pointer dereference in quota check Date: Mon, 5 Nov 2018 11:00:52 +0000 Message-Id: <20181105110052.31759-1-lhenriques@suse.com> In-Reply-To: <20181101065318.2cylxol6d444nzeu@kili.mountain> References: <20181101065318.2cylxol6d444nzeu@kili.mountain> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) Reported-by: Dan Carpenter Link: https://lkml.kernel.org/n/20181101065318.2cylxol6d444nzeu@kili.mountain Fixes: b7a2921765cf ("ceph: quota: support for ceph.quota.max_files") Signed-off-by: Luis Henriques --- 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;