From patchwork Sun Aug 21 15:30:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 1083472 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7LFURXc006136 for ; Sun, 21 Aug 2011 15:30:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752638Ab1HUPa1 (ORCPT ); Sun, 21 Aug 2011 11:30:27 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:38342 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092Ab1HUPa0 (ORCPT ); Sun, 21 Aug 2011 11:30:26 -0400 Received: by bke11 with SMTP id 11so3168644bke.19 for ; Sun, 21 Aug 2011 08:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer; bh=JkXuj1mOEXyZBPc+aZf1V0V3UtUK9OtYIorfQJ4gWMc=; b=oxrFOq4Geux8Ot9GRhTIsEcJEUhRZwu7t1xsGuLo1uV5q7hU8EfVB4WPXDMXrELGpw kOuJqWyHXDbLbBHHv9VLMzo2qfLakVHwQWwsKSOmL1RDCuto7OzIr3KAV0y74y2cdCop rk+l6sTgj8zDRo8eA2f/VaA8oVr4Hjk25inV4= Received: by 10.204.157.2 with SMTP id z2mr532193bkw.107.1313940625406; Sun, 21 Aug 2011 08:30:25 -0700 (PDT) Received: from localhost.localdomain ([95.84.0.255]) by mx.google.com with ESMTPS id z6sm1628514bks.57.2011.08.21.08.30.23 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Aug 2011 08:30:24 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH] CIFS: Fix ERR_PTR dereference in cifs_get_root Date: Sun, 21 Aug 2011 19:30:15 +0400 Message-Id: <1313940615-3347-1-git-send-email-piastryyy@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 21 Aug 2011 15:30:27 +0000 (UTC) move it to the beginning of the loop. Signed-off-by: Pavel Shilovsky Reviewed-by: Jeff Layton --- fs/cifs/cifsfs.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 0435bb9..8b79122 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -559,6 +559,12 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) struct inode *dir = dentry->d_inode; struct dentry *child; + if (!dir) { + dput(dentry); + dentry = ERR_PTR(-ENOENT); + break; + } + /* skip separators */ while (*s == sep) s++; @@ -574,10 +580,6 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb) mutex_unlock(&dir->i_mutex); dput(dentry); dentry = child; - if (!dentry->d_inode) { - dput(dentry); - dentry = ERR_PTR(-ENOENT); - } } while (!IS_ERR(dentry)); _FreeXid(xid); kfree(full_path);