Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936094AbdLRT1e (ORCPT ); Mon, 18 Dec 2017 14:27:34 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:34205 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934493AbdLRT1c (ORCPT ); Mon, 18 Dec 2017 14:27:32 -0500 X-Google-Smtp-Source: ACJfBoucjhZ8DD/VIzxfErFElJmDPBc3xoj5vIm29oApzCFYIdgSARSEi9ktAbkqmapl6Y/HH1o6dQ== Message-ID: <1513625246.3434.0.camel@gmail.com> Subject: Re: [PATCH] Staging: irda: Do not check for NOT NULL before kfree() From: Shreeya Patel To: Stephen Hemminger Cc: samuel@sortiz.org, gregkh@linuxfoundation.org, netdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Date: Tue, 19 Dec 2017 00:57:26 +0530 In-Reply-To: <20171218112038.15626e20@xeon-e3> References: <1513624290-2965-1-git-send-email-shreeya.patel23498@gmail.com> <20171218112038.15626e20@xeon-e3> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 719 Lines: 28 On Mon, 2017-12-18 at 11:20 -0800, Stephen Hemminger wrote: > On Tue, 19 Dec 2017 00:41:30 +0530 > Shreeya Patel wrote: > > > > > Do not check for NOT NULL before calling kfree because if the > > pointer is NULL, no action occurs. > > Done using the following semantic patch by coccinelle. > > > > @@ > > expression ptr; > > @@ > > > > - if (ptr != NULL) { > >   kfree(ptr); > >   ptr = NULL; > > - } > > > > The semantic patch has the effect of adding an assignment > > of ptr to NULL in the case where ptr is NULL already. > > > > Signed-off-by: Shreeya Patel > Please read drivers/staging/irda/TODO Oh, I was not knowing about it. Thank you >