Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp412563iof; Mon, 6 Jun 2022 06:00:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfVpvi2wAF3n+MW53UQgzI6fC+ySTZ7/8VFTLFBnB4Ua9TYidldPcUOKpdjFG7gRXbrSWV X-Received: by 2002:a65:60d3:0:b0:39c:f431:5859 with SMTP id r19-20020a6560d3000000b0039cf4315859mr20817318pgv.442.1654520453238; Mon, 06 Jun 2022 06:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654520453; cv=none; d=google.com; s=arc-20160816; b=Mx3fL9CqVNKBGSwmYbv4DtH5mq6P77k/Wg47kTbunbtRIfAu71jaMP718ZExLvWdDq VKBg/kRyxy1q5fQfndRYAavNY79zHWatCEP67uQMDeMaYEvnbpSwHIOQOsHSek1k1ZuJ okN+oY5+crf0xyIF+4yFmLeAnv7f3OKGPeEgRh91D3GY7EoF0E6JWRJn6lZQFS0gexWK GQnCSFTBOZs8QWI3FQv0rf1jyFFBuQeH8pcFCDi6uWyxmTDeNk/8uwW9XKEoa9XLnh1b acmcJZtmQ/UNR0pJtisljqNW+q+/2u0nKfGXbMVIqvsChlR3aTybSuAPkJ0HtI5p4Vhx 9gzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=sCzRKMyO8HUX8TZTo6HNb3UO0nIl9wnT8p4eg9/ndq4=; b=xMCOQlk0odTp7LGMIzYKN+JG5DaHKHLDLEFPJ8Fv+gFoWU2jmYfxf+Nqb3PFXkz3l6 Fx2WziI4GzFbJMF97Zoae58g3pnVU1r7u0Ry4VYK1wnu0bXI8dkjhm5wUchbKcvrEsIG wcqt7ifQFs/DOre2amjsn++a6gtlco5BFTMO3bUE6g3718bzszTYt0oWk3YSWrddUKeR Wij07VvgvurzwKjO7v0qHVQkRtVbG+pFTM9fictZOLqDTKnmoTfS3xSIAX0NDKzp1QfM 0c6cVGd06POvU5i7Jovfahz824W749o2zPi9HSF+1nUL7SuU4t8JfAqUlxdOLKLH2x5K lBLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x3-20020a1709029a4300b00156bc537059si8449753plv.17.2022.06.06.06.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 06:00:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11CFB87A2A; Mon, 6 Jun 2022 05:56:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238007AbiFFM4p (ORCPT + 99 others); Mon, 6 Jun 2022 08:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237991AbiFFM4n (ORCPT ); Mon, 6 Jun 2022 08:56:43 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E307735A80; Mon, 6 Jun 2022 05:56:41 -0700 (PDT) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LGtk21XPvz1K9CP; Mon, 6 Jun 2022 20:54:50 +0800 (CST) Received: from container.huawei.com (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 6 Jun 2022 20:56:35 +0800 From: Ziyang Xuan To: , , , , , , , CC: Subject: [PATCH] hwmon: (occ) Delete unnecessary NULL check Date: Mon, 6 Jun 2022 21:14:01 +0800 Message-ID: <20220606131401.4053036-1-william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kvfree(NULL) is safe. NULL check before kvfree() is not needed. Delete them to simplify the code. Generated by coccinelle script: scripts/coccinelle/free/ifnullfree.cocci Signed-off-by: Ziyang Xuan --- drivers/hwmon/occ/p9_sbe.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/occ/p9_sbe.c b/drivers/hwmon/occ/p9_sbe.c index 42fc7b97bb34..01405ae2f9bd 100644 --- a/drivers/hwmon/occ/p9_sbe.c +++ b/drivers/hwmon/occ/p9_sbe.c @@ -55,8 +55,7 @@ static bool p9_sbe_occ_save_ffdc(struct p9_sbe_occ *ctx, const void *resp, mutex_lock(&ctx->sbe_error_lock); if (!ctx->sbe_error) { if (resp_len > ctx->ffdc_size) { - if (ctx->ffdc) - kvfree(ctx->ffdc); + kvfree(ctx->ffdc); ctx->ffdc = kvmalloc(resp_len, GFP_KERNEL); if (!ctx->ffdc) { ctx->ffdc_len = 0; @@ -171,8 +170,7 @@ static int p9_sbe_occ_remove(struct platform_device *pdev) ctx->sbe = NULL; occ_shutdown(occ); - if (ctx->ffdc) - kvfree(ctx->ffdc); + kvfree(ctx->ffdc); return 0; } -- 2.25.1