From patchwork Fri Dec 19 16:06:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 5520571 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 36F4EBEEA8 for ; Fri, 19 Dec 2014 16:06:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4817C2013A for ; Fri, 19 Dec 2014 16:06:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 441C920121 for ; Fri, 19 Dec 2014 16:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751821AbaLSQGh (ORCPT ); Fri, 19 Dec 2014 11:06:37 -0500 Received: from cantor2.suse.de ([195.135.220.15]:43116 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751762AbaLSQGg (ORCPT ); Fri, 19 Dec 2014 11:06:36 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7154DAC19 for ; Fri, 19 Dec 2014 16:06:35 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 026D1DAA27; Fri, 19 Dec 2014 17:06:34 +0100 (CET) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: David Sterba Subject: [PATCH 4/6] btrfs-progs: check result of first_cache_extent Date: Fri, 19 Dec 2014 17:06:34 +0100 Message-Id: <813550c84636f7d570c541c22eee60b11346b4f3.1419005022.git.dsterba@suse.cz> X-Mailer: git-send-email 2.1.3 In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 If the tree's empty, we'll get NULL and dereference it. Resolves-Coverity-CID: 1248828 Signed-off-by: David Sterba Reviewed-by: Eric Sandeen --- cmds-check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index 6eea36c2f52c..3e7a4ebdce44 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -8075,6 +8075,8 @@ static void free_roots_info_cache(void) struct root_item_info *rii; entry = first_cache_extent(roots_info_cache); + if (!entry) + break; remove_cache_extent(roots_info_cache, entry); rii = container_of(entry, struct root_item_info, cache_extent); free(rii);