Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1820355imu; Tue, 6 Nov 2018 05:01:02 -0800 (PST) X-Google-Smtp-Source: AJdET5c0k701N+M+TPPkrgyKHW+zpgS2NB+BviNp33lIupsNk1eourx3UteMMOkTJcj+xgty6Dmu X-Received: by 2002:a62:14d4:: with SMTP id 203-v6mr25882106pfu.221.1541509262064; Tue, 06 Nov 2018 05:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541509262; cv=none; d=google.com; s=arc-20160816; b=1IhT+gavfUZ43TbRhy3FSIlck1zwzvUtVPIVZ5+YZSrEs5NSO/VF63Uot1hOlWsROO 8HIW4jZbUkesm5/s90NqeqnplLPiBwne3nw9WjXF3neXN2btNdohyNCPAYT5L9lKtSLZ j7Xe0EokyESw0KE+VP2QC6vhRjs4l3uAsWmmXIYgAUSUYIujoIX+9xRxldYJT7JrB4D/ iQPLNnMk6gBKe2Ne8yEim2vg4IhXlXKInjob95FfRWseJsMLVtSPcnLFlPwatu4Bh/5j AOx0PfPpprOoDERVvxZb6PKvxEK5Om+P38SXRIdUSw9NO0dRpqN2ZsNUAuhJTZAIG6ue gMqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=BnOs6QHvapOFFuqTLjMsXJDSh28eFy3BA6xQ2n7C8xY=; b=st4hyT2VtJqKntSNllyPqAqoKIDVAAjcFX0YzotozI243AuzGnzIeUxaWGaNqhmW6l +ogjt8wMVbw9DmCF+ItyQVCFXDsZVrpOWs3fPhOs2cZWSz5Ii5JvVkXXZrjTePdpDjY0 LSriJcAHR+JaKBYYJbJEaVZs3GW6fsf1A+fXvasOG1tTLHZP5BORQA1P2gbewN84+Fsf KoTETvnVYns4/hmMymn/5rcNyCL03/tp3gKpPo7eQY0TuhWmWYsCQmLStw9D2ndjx8Uh LYugm9KdmAe39fCfx096OVWMEeCSEYG2ggJgLuhP0nJ4g7ENQscmhFw+MTXJNcnVpoyn O2Wg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i35-v6si35818407plg.252.2018.11.06.05.00.45; Tue, 06 Nov 2018 05:01:02 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388137AbeKFWZY convert rfc822-to-8bit (ORCPT + 99 others); Tue, 6 Nov 2018 17:25:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53432 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387596AbeKFWZY (ORCPT ); Tue, 6 Nov 2018 17:25:24 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 14A008AE5A; Tue, 6 Nov 2018 13:00:18 +0000 (UTC) Received: from ovpn-12-92.pek2.redhat.com (ovpn-12-92.pek2.redhat.com [10.72.12.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 455C41710E; Tue, 6 Nov 2018 13:00:14 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.1 \(3445.101.1\)) Subject: Re: [PATCH] ceph: quota: fix null pointer dereference in quota check From: "Yan, Zheng" In-Reply-To: <20181105110052.31759-1-lhenriques@suse.com> Date: Tue, 6 Nov 2018 21:00:09 +0800 Cc: Sage Weil , Ilya Dryomov , Dan Carpenter , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <3AD4F375-E9DE-485D-B2DA-A938AC4A3F0C@redhat.com> References: <20181101065318.2cylxol6d444nzeu@kili.mountain> <20181105110052.31759-1-lhenriques@suse.com> To: Luis Henriques X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 06 Nov 2018 13:00:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 5, 2018, at 19:00, Luis Henriques wrote: > > 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; Applied, thanks. Yan, Zheng