From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933526AbcHNUpv (ORCPT ); Sun, 14 Aug 2016 16:45:51 -0400 Received: from tex.lwn.net ([70.33.254.29]:42951 "EHLO vena.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbcHNUpp (ORCPT ); Sun, 14 Aug 2016 16:45:45 -0400 Date: Sun, 14 Aug 2016 14:45:43 -0600 From: Jonathan Corbet To: Mark D Rustad Cc: Jean Delvare , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Markus Elfring Subject: Re: [PATCH] CodingStyle: Clarify and complete chapter 7 Message-ID: <20160814144543.1a12bced@lwn.net> In-Reply-To: References: <20160725142906.003bfe06@endymion> <20160814123024.79c2082a@lwn.net> Organization: LWN.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 14 Aug 2016 13:12:33 -0700 Mark D Rustad wrote: > >> + err: > >> kfree(foo->bar); > >> kfree(foo); > >> return ret; > >> > >> The bug in this code is that on some exit paths "foo" is NULL. Normally the > > > > ...except that kfree() can handle null pointers just fine, so this isn't > > actually a bug, right? Someday when somebody has time it would be good to > > come up with a better example. > > But if foo is NULL, foo->bar is not NULL and so kfree will have a problem > with it. So this is a bug. Oops, sigh, duh. OK, ignore me. (Though technically kfree will not have a problem with it, since things won't get that far.. :) jon