From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C1A6C433EF for ; Mon, 6 Jun 2022 14:19:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239755AbiFFOTb (ORCPT ); Mon, 6 Jun 2022 10:19:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239672AbiFFOTW (ORCPT ); Mon, 6 Jun 2022 10:19:22 -0400 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 934B369CEC; Mon, 6 Jun 2022 07:19:21 -0700 (PDT) Received: by mail-oi1-x22d.google.com with SMTP id y69so6050400oia.7; Mon, 06 Jun 2022 07:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=yxqyZ8yixmu1+DZ929D04d1QQALsRCYwyUVuVfKay8c=; b=g96pMmdBLJ92I1YvWrCJUUzDj/TLj3jIshQjRbceVvTxzSE4T16TMe7lRXAdqIFPxB dsHy9kXX7CKGsO7wBAaWiORozC/g7oCm1Q5p512vWZQ8sgXxkcBBRq/bo3qbLU8zHl8Z DBXOgLUqNyswY644L94LqxlGXjdrI6q5FYLuQ/k3WdwRhBavpbKy3c1kXSjCyTZSbD8b RVw8D2hy6zzWnByYruW3qUoEfrxYcL8tSTeI3Ya6DcW0xr0wY3meP80UD8b1oOa7sm5A SX/jMibC2DLQbNLJkKHdbp8NolbDh4gLBUZKRKnY/9juZ60d8t6nQ32o1HUBTc3exyv6 sgKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mime-version:content-disposition; bh=yxqyZ8yixmu1+DZ929D04d1QQALsRCYwyUVuVfKay8c=; b=ZSucAk2gE7O/YRBeHK6eIY2tvW5vHCCfkAttgRXUHu9bBc7AB10uueNPyJufOOlk6D 9bVPF1oJOPHKuGAB6V61SYcj6ilLSk9lCLSdAtDFrs5ZBL/dJou3xAoalpwKypMlLpWs /SnTKnPR/zem9Iq9DpsjFPa+Ai22VV39THT1hYvo82nCNZ72W7eAOBiDb7IBAyvK+qU8 oJrcC1b0xT3yPtzC09nI11J1phkL2XCzxlxZS93QPX8QeBa45YD72hguXMYD69w2cxOW pRpiFMAK5vv/U/BZA3C9rOl9xUKIiIiEsrGr++z5aNnv35gDNWLRPxgpUUCEMZYgJvCr Va6g== X-Gm-Message-State: AOAM530eYJ8m+kKOOh0EZlgDPrCYYInvt4i3dinJbt/lMBQLlgmKBXfm lPem1b80BIBBTSkdZy0iljWUh7tzhgc= X-Google-Smtp-Source: ABdhPJzZ7NP5aaCxbfTMHn0rWYPbFnDJzmUAaoaw4M2ZgD5NhCtc+5SBzMo6Cyu19yask3Y+I/iNKA== X-Received: by 2002:a05:6808:18a5:b0:32e:9741:15b with SMTP id bi37-20020a05680818a500b0032e9741015bmr2655071oib.113.1654525160774; Mon, 06 Jun 2022 07:19:20 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id lx15-20020a0568704b8f00b000f5e89a9c60sm6631471oab.3.2022.06.06.07.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 07:19:19 -0700 (PDT) Sender: Guenter Roeck Date: Mon, 6 Jun 2022 07:19:18 -0700 From: Guenter Roeck To: Ziyang Xuan Cc: jdelvare@suse.com, eajames@linux.ibm.com, joel@jms.id.au, penberg@kernel.org, akpm@linux-foundation.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hwmon: (occ) Delete unnecessary NULL check Message-ID: <20220606141918.GA3747239@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 06, 2022 at 09:14:01PM +0800, Ziyang Xuan wrote: > 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 Applied to hwmon-next. Thanks, Guenter > --- > 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 >