Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935686AbdLRTUp (ORCPT ); Mon, 18 Dec 2017 14:20:45 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:40789 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934949AbdLRTUk (ORCPT ); Mon, 18 Dec 2017 14:20:40 -0500 X-Google-Smtp-Source: ACJfBotl43BVQFqehVWXO1NlXqiUoge0+w0s84eGpFBxRKa6beLnsbgqpGIaunn2BzASrXhnQOiE+Q== Date: Mon, 18 Dec 2017 11:20:38 -0800 From: Stephen Hemminger To: Shreeya Patel Cc: samuel@sortiz.org, gregkh@linuxfoundation.org, netdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Staging: irda: Do not check for NOT NULL before kfree() Message-ID: <20171218112038.15626e20@xeon-e3> In-Reply-To: <1513624290-2965-1-git-send-email-shreeya.patel23498@gmail.com> References: <1513624290-2965-1-git-send-email-shreeya.patel23498@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 564 Lines: 22 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