[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1350069693.15966.591.camel@mfleming-mobl1.ger.corp.intel.com>
Date: Fri, 12 Oct 2012 20:21:33 +0100
From: Matt Fleming <matt.fleming@...el.com>
To: Khalid Aziz <khalid@...ehiking.org>
Cc: Andy Whitcroft <apw@...onical.com>,
Matthew Garrett <mjg@...hat.com>,
Jeremy Kerr <jeremy.kerr@...onical.com>,
linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/5] efivarfs: efivarfs_create() ensure we drop our
reference on inode on error
On Fri, 2012-10-12 at 13:03 -0600, Khalid Aziz wrote:
> This does not read right. If kzalloc() fails, var will be a NULL
> pointer. This code will set err to -ENOMEM and jump to out: where since
> err is non-zero, this code will call kfree(Var) but var is a NULL
> pointer at this point. Now kfree() does check for NULL pointer and this
> will not cause any serious problems but why call kfree for a NULL
> pointer?
This is a common idiom used throughout the kernel to simply error paths.
As you noted, calling kfree(NULL) is harmless and there's certainly no
need to worry about the overhead of calling kfree() without doing any
freeing since the error path is also the slow path.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists