From patchwork Thu Oct 13 15:15:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 9375149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 828A960487 for ; Thu, 13 Oct 2016 15:17:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 748612A130 for ; Thu, 13 Oct 2016 15:17:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 695AA2A135; Thu, 13 Oct 2016 15:17:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 770602A130 for ; Thu, 13 Oct 2016 15:17:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969AbcJMPQu (ORCPT ); Thu, 13 Oct 2016 11:16:50 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:59115 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754581AbcJMPQF (ORCPT ); Thu, 13 Oct 2016 11:16:05 -0400 Received: from ayla.of.borg ([84.193.137.253]) by andre.telenet-ops.be with bizsmtp id v3Fe1t0025UCtCs013FeeW; Thu, 13 Oct 2016 17:15:38 +0200 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1buhjN-0007lF-UB; Thu, 13 Oct 2016 17:15:37 +0200 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1buhjQ-0000Yj-Mq; Thu, 13 Oct 2016 17:15:40 +0200 From: Geert Uytterhoeven To: Zheng Yan , Ilya Dryomov Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] ceph: Fix uninitialized dentry pointer in ceph_real_mount() Date: Thu, 13 Oct 2016 17:15:37 +0200 Message-Id: <1476371737-2116-1-git-send-email-geert@linux-m68k.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP fs/ceph/super.c: In function ‘ceph_real_mount’: fs/ceph/super.c:818: warning: ‘root’ may be used uninitialized in this function If s_root is already valid, dentry pointer root is never initialized, and returned by ceph_real_mount(). This will cause a crash later when the caller dereferences the pointer. Fix this by initializing root early. Fixes: ce2728aaa82bbeba ("ceph: avoid accessing / when mounting a subpath") Signed-off-by: Geert Uytterhoeven --- Compile-tested only. --- fs/ceph/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index a29ffce981879d5f..794c5fd0e0cf5e45 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -821,7 +821,8 @@ static struct dentry *ceph_real_mount(struct ceph_fs_client *fsc) dout("mount start %p\n", fsc); mutex_lock(&fsc->client->mount_mutex); - if (!fsc->sb->s_root) { + root = fsc->sb->s_root; + if (!root) { const char *path; err = __ceph_open_session(fsc->client, started); if (err < 0)