Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1497217iog; Tue, 14 Jun 2022 07:15:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyE/4No9rq8+Kef+zcWNUACsJRavXxN3/Zrh12PRXg6vhd67U9J1/JR6Qkp5p5oZYl9HRpj X-Received: by 2002:a17:907:7810:b0:6e7:ef73:8326 with SMTP id la16-20020a170907781000b006e7ef738326mr4413666ejc.429.1655216103826; Tue, 14 Jun 2022 07:15:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655216103; cv=none; d=google.com; s=arc-20160816; b=ydC/Y1qikBOkK//dXFVCOqtz9O2plf7sk975aRFmG9FUVJumGekCxIqhIq2dSGNAFR uDF5uCAoTAkfv+T/JhPKbqzcDzYgK3XUER7ltLtKguHjorQp+AMXycvQx6FCYNMfoV+M 9x8BZ3Lqronp61GFdl32m1zaCd3Q282z5xcEI//CEXOmPnR0KSuNeEndggYukKyXhdRL aGtwXbIsYqkg2AevQDUK6+Ox/8WuflQMhr4Oj/AsMjdK+/BmoZuzL9coUJugZYVm219r vAkWVQhWPj8h3uouudUK2w8XaoNX7mBi4Fa8FNY5RYs36UI0AV1puEVbXxIEbz+r3vBB ENEg== 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=Py3w9Y9sOuhFG0W3HiAbHlmL4kUGUiqQC/SOYnStBo0=; b=jKPsdgblAT2MRN3CDhjElH3sv2Mp+ARzzP/m+VQM97wed4F44SdYl3LDd5l88ajvpA b7V9G0LUIA1sqnkDKf7vbVZdVzmzZIxr3k47CPwJGmnnUl4LTypEUUJPNJFfJTf3Zhbr LpLabnoyRuSPBWSSXpn3NtUeJLMOWjmYRB2dHeyehCzFnD/unUaMswyy3LkDExyYE+eH Vovlhxjesbgu1Z4jCwHSbrSE0NzZEtqTs5BiKmdRSiKIxDuMKhTB6DkEUMqwF7TxdKI+ +FbcpuyP8Tdp94zrRGar1F9NUZkpm4KHVJgnHinBrdXJwYQoSKHH2huZuJRo+5xMm39w /Yog== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020a1709067cd200b006f4326c816bsi10182513ejp.357.2022.06.14.07.14.33; Tue, 14 Jun 2022 07:15:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235715AbiFNNd0 (ORCPT + 99 others); Tue, 14 Jun 2022 09:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245704AbiFNNc0 (ORCPT ); Tue, 14 Jun 2022 09:32:26 -0400 Received: from hust.edu.cn (mail.hust.edu.cn [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489962F1; Tue, 14 Jun 2022 06:32:24 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 25EDUYte030219-25EDUYth030219 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 14 Jun 2022 21:30:38 +0800 From: Dongliang Mu To: Jean Delvare , Guenter Roeck , Eddie James , Joel Stanley , Andrew Morton , Dongliang Mu , "Matthew Wilcox (Oracle)" Cc: Pekka Enberg , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] hwmon: (occ) remove NULL check before kvfree Date: Tue, 14 Jun 2022 21:30:22 +0800 Message-Id: <20220614133025.146745-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Dongliang Mu kvfree can handle NULL pointer as its argument. According to coccinelle isnullfree check, remove NULL check before kvfree operation. Signed-off-by: Dongliang Mu --- v1->v2: modify the commit title and signature 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.35.1