Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp502106iof; Mon, 6 Jun 2022 07:31:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9OQpRWHn5mG+UbpD9rGGhU4zWsl0Z4dyHAdEScz3kJXxXcTZOFFXmX0MlG2/nowYQ1Emw X-Received: by 2002:a17:902:728a:b0:166:3b4f:f6eb with SMTP id d10-20020a170902728a00b001663b4ff6ebmr23479280pll.16.1654525880827; Mon, 06 Jun 2022 07:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654525880; cv=none; d=google.com; s=arc-20160816; b=bI/b7KPIaw8301E/sa+XJSgR5pMk2uRInn8KJPwpSHuyo46vIAT9I1XkpLU4NpbF60 No0Hm+5ZSiEI2UaQxe9gexdXQJGlxUuJ/V2cql3D/zWvybDmTgE0EAETx7ZLKouq/Pye z7PBprrCJGkL1rlsFpaQpl82XQvVj5n5YQ3ddN6jLnqP5iBvN5UVvrtzMQLz+kHGkEV/ IEzBpmw7uhfni2X2/hwbMRsoITPVcS5ghiGrq4Z6Zr7ftWe4UW9ooP9PS7fWc56MsF8k uPf/lKPFy8f9u5G79IOkJh3DC1DPUBmCPdICMtL9koDAGNvUVPttikWf1paXFM2Kzke0 q+/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:sender:dkim-signature; bh=yxqyZ8yixmu1+DZ929D04d1QQALsRCYwyUVuVfKay8c=; b=hyfzPttchJTEQV23jSy1nxcIqNBGx3xfgW/rkfnp2Fzw23K6qkgA8F4USGZsiuVRlt Z/V7tvR3I3n2nvlOJou22FLHexsFJN4H34ykW3N6J4hCY980YPV9+ybltpsUVY9QeO0s TGs3XJunHkwaiGQNSQ+g1c1syeLZLHPzsPqzh7Sk/Y6XGtWzbAwzvyLW3v3RTo044sdz /D8mlNVrr7Qp121XPItDXkLtOD05O15leLSvV6V8A9Vu2Z7JqiiGwhzyC+nTfhdhktCv FOb4AIE5S5sD3SCmPDXTsFTql/Me8AKoNBIsGCp5MbrBnIXF/qnjU8xmMbuZhdFGAHyz P5HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g96pMmdB; 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 Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oa4-20020a17090b1bc400b001d9752b43absi22221797pjb.137.2022.06.06.07.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 07:31:20 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=g96pMmdB; 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 953E19876B; Mon, 6 Jun 2022 07:19:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239675AbiFFOTa (ORCPT + 99 others); Mon, 6 Jun 2022 10:19:30 -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-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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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 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 >