From patchwork Thu Jun 5 12:22:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 4304551 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66D7DBEEAA for ; Thu, 5 Jun 2014 11:24:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E1332016C for ; Thu, 5 Jun 2014 11:24:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AD9DA201DD for ; Thu, 5 Jun 2014 11:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751802AbaFELYb (ORCPT ); Thu, 5 Jun 2014 07:24:31 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:36327 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751783AbaFELY3 (ORCPT ); Thu, 5 Jun 2014 07:24:29 -0400 Received: by mail-wi0-f180.google.com with SMTP id hi2so3251361wib.13 for ; Thu, 05 Jun 2014 04:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Bj7gzm5PQTg7sFJ5pa68c1ei2qGVxk80KZ9wncP+u0=; b=tx1iOHN78xgIKYjqcDXmP2qyc3xvMQBrE053hEGyiO8YjvQYtBS5S+bhfkG3qUVORB i+a6q9IrsC9IUUbl/b95CAV3kI1FglyvTBSmat1u+N16+aT0MwkG8rnNnGdJzQ/Yq7yU FL8hfruz2qJWzuRXStXkdaYGyFxjU5l+W3Rog8Iha27SVvFeKxs2/U8pfUVW0+PSOeYo 81n85qM/QUYEqdfNy/25bOGhV5U+/Zya3PHe4tSK1NRpIWA4jU6bXIxxwzEvRiYzF96C Kj++JCbQG6F0Aixyk8TqWmMulbEqAE0SKbniZmG9Rtu1CZ5gBCTeSimweCOaCTbPyKwo hTYA== X-Received: by 10.194.85.225 with SMTP id k1mr81440371wjz.49.1401967468380; Thu, 05 Jun 2014 04:24:28 -0700 (PDT) Received: from debian-vm3.lan (bl13-158-240.dsl.telepac.pt. [85.246.158.240]) by mx.google.com with ESMTPSA id bl3sm2142476wib.9.2014.06.05.04.24.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Jun 2014 04:24:27 -0700 (PDT) From: Filipe David Borba Manana To: linux-btrfs@vger.kernel.org Cc: Filipe David Borba Manana Subject: [PATCH 3/3] Btrfs: don't release invalid page in btrfs_page_exists_in_range() Date: Thu, 5 Jun 2014 13:22:26 +0100 Message-Id: <1401970946-25269-3-git-send-email-fdmanana@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1401970946-25269-1-git-send-email-fdmanana@gmail.com> References: <1401970946-25269-1-git-send-email-fdmanana@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In inode.c:btrfs_page_exists_in_range(), if the page we got from the radix tree is an exception entry, which can't be retried, we exit the loop with a non-NULL page and then call page_cache_release against it, which is not ok since it's not a valid page. This could also make us return true when we shouldn't. Signed-off-by: Filipe David Borba Manana --- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index f265f41..477e64a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6776,6 +6776,7 @@ bool btrfs_page_exists_in_range(struct inode *inode, loff_t start, loff_t end) * here as an exceptional entry: so return it without * attempting to raise page count. */ + page = NULL; break; /* TODO: Is this relevant for this use case? */ }