Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2761950imm; Sun, 12 Aug 2018 23:19:05 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyBLD0yc2g3QbCYneKO44q61GzW8OZIQrEe48Q6n3ZIYGyZvZMXWlNHgb8XXE6DjO9txGai X-Received: by 2002:a17:902:1a2:: with SMTP id b31-v6mr15067277plb.279.1534141145569; Sun, 12 Aug 2018 23:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534141145; cv=none; d=google.com; s=arc-20160816; b=c4zUI1zLCC6NNdKmnYbZax90VwalO+knsIlV/U1ep2H+POz0m+j6wyf75UyC8AdmCf GTZj/6PSbV2iuFLQth5U7yGTJpu53By5QUCUM7lIPYG9aPOql5XHAcv7B3UAA00g4CE5 NQ+GRH5QXC7J69rznQ0qfqoytZxzgFT8C6/6Nchn355veHnLOLFQZ/wTuat91PoUatCe NUWxHtMJPp/FOVw0GW9YQygKDEwB4EICJEpG8Or2lwIMnxSHvf4mB2W5ZjrlQXnjZHBt 0zUhxknG0ph337NEDUdk+PLshJizR28O9m7ImOlL7GdCJNZ4Nv+ghDT2KuEjflSS6y2M 8dXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=gS/YbYovrwGwJmUErWidOdV1FpqvCNuCoR4EY1j6UAg=; b=AbHo9pqkV6syLALdUPIBovSy9SYGjJufYMUmMaaL5Js3bjpfmuyc2IgE3mgOclQZOB I4iWxsdcPYk+5z5/meX/H5UaBP0nfTjuJ0UiJKOB52Q+Mad7dLE2TRyfqXR5qaY24Avg Rx6wpb8LRgvjysPybicD4qBWFaMEupND1OezSkA/ZTqoID/fFQJxCof0NIjah9HeP2jI qolSO4sY2fWDbKQombSu5tuXzs0b4EguxHZYDUeo20WSAkUNrTGM8hqbWdlMyT+Iuq5H ot0lyrxjpbRYrOKUoRMhd5nB7UUsNg4VK9N5scZcQzjqbO6wygTIQq5Qls4lCMzJZoh5 +DRg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t71-v6si16230793pgd.271.2018.08.12.23.18.50; Sun, 12 Aug 2018 23:19:05 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728339AbeHMI6s (ORCPT + 99 others); Mon, 13 Aug 2018 04:58:48 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:43895 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726345AbeHMI6r (ORCPT ); Mon, 13 Aug 2018 04:58:47 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 1657029BD83C3; Mon, 13 Aug 2018 14:17:56 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.399.0; Mon, 13 Aug 2018 14:17:55 +0800 From: zhong jiang To: , , CC: , Subject: [PATCH] btrfs:free-space-cache: remove unneeded NULL check before kfree Date: Mon, 13 Aug 2018 14:06:08 +0800 Message-ID: <1534140369-11578-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Kfree has taken the null pointer into account. So remove the check before kfree. The issue is detected with the help of Coccinelle. Signed-off-by: zhong jiang --- fs/btrfs/free-space-cache.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index c3888c1..69d639f 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -2110,8 +2110,7 @@ static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl, out: if (info) { - if (info->bitmap) - kfree(info->bitmap); + kfree(info->bitmap); kmem_cache_free(btrfs_free_space_cachep, info); } @@ -3605,8 +3604,7 @@ int test_add_free_space_entry(struct btrfs_block_group_cache *cache, if (info) kmem_cache_free(btrfs_free_space_cachep, info); - if (map) - kfree(map); + kfree(map); return 0; } -- 1.7.12.4