From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arnd Bergmann Subject: Re: [PATCH 1/4] gpiolib: introduce descriptor-based GPIO interface Date: Wed, 9 Jan 2013 11:52:29 +0000 Message-ID: <201301091152.30047.arnd@arndb.de> References: <1357629535-26033-1-git-send-email-acourbot@nvidia.com> <20130109104414.GF3931@n2100.arm.linux.org.uk> <20130109111055.GG3931@n2100.arm.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130109111055.GG3931-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devicetree-discuss-bounces+gldd-devicetree-discuss=m.gmane.org-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Sender: "devicetree-discuss" To: Russell King - ARM Linux Cc: linux-arch-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux Kernel Mailing List , Alexandre Courbot , "linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org" , "devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org" , Guenter Roeck List-Id: linux-arch.vger.kernel.org On Wednesday 09 January 2013, Russell King - ARM Linux wrote: > d = debugfs_create_dir("pm_debug", NULL); > if (IS_ERR_OR_NULL(d)) > return PTR_ERR(d); > > Well, covered above. NULL is success here. This one is actually worse, because in case of debugfs_create_dir, a negative error code is documented to mean "success": The debugfs functions intentionally return ERR_PTR(-ENODEV) when debugfs is disabled so that any code checking for NULL pretends it is a valid pointer, but that code is only allowed to pass this pointer into other debugfs functions that are also stubbed out and never dereference it. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from moutng.kundenserver.de ([212.227.126.186]:62070 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756635Ab3AILwn (ORCPT ); Wed, 9 Jan 2013 06:52:43 -0500 From: Arnd Bergmann Subject: Re: [PATCH 1/4] gpiolib: introduce descriptor-based GPIO interface Date: Wed, 9 Jan 2013 11:52:29 +0000 References: <1357629535-26033-1-git-send-email-acourbot@nvidia.com> <20130109104414.GF3931@n2100.arm.linux.org.uk> <20130109111055.GG3931@n2100.arm.linux.org.uk> In-Reply-To: <20130109111055.GG3931@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-ID: <201301091152.30047.arnd@arndb.de> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Russell King - ARM Linux Cc: linux-arch@vger.kernel.org, Linus Walleij , Linux Kernel Mailing List , Grant Likely , Alexandre Courbot , Guenter Roeck , "devicetree-discuss@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" Message-ID: <20130109115229.dCqQomMH8OmcWFs_kuvQnz8yhcJfU27nWagLnx04joM@z> On Wednesday 09 January 2013, Russell King - ARM Linux wrote: > d = debugfs_create_dir("pm_debug", NULL); > if (IS_ERR_OR_NULL(d)) > return PTR_ERR(d); > > Well, covered above. NULL is success here. This one is actually worse, because in case of debugfs_create_dir, a negative error code is documented to mean "success": The debugfs functions intentionally return ERR_PTR(-ENODEV) when debugfs is disabled so that any code checking for NULL pretends it is a valid pointer, but that code is only allowed to pass this pointer into other debugfs functions that are also stubbed out and never dereference it. Arnd From mboxrd@z Thu Jan 1 00:00:00 1970 From: arnd@arndb.de (Arnd Bergmann) Date: Wed, 9 Jan 2013 11:52:29 +0000 Subject: [PATCH 1/4] gpiolib: introduce descriptor-based GPIO interface In-Reply-To: <20130109111055.GG3931@n2100.arm.linux.org.uk> References: <1357629535-26033-1-git-send-email-acourbot@nvidia.com> <20130109104414.GF3931@n2100.arm.linux.org.uk> <20130109111055.GG3931@n2100.arm.linux.org.uk> Message-ID: <201301091152.30047.arnd@arndb.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wednesday 09 January 2013, Russell King - ARM Linux wrote: > d = debugfs_create_dir("pm_debug", NULL); > if (IS_ERR_OR_NULL(d)) > return PTR_ERR(d); > > Well, covered above. NULL is success here. This one is actually worse, because in case of debugfs_create_dir, a negative error code is documented to mean "success": The debugfs functions intentionally return ERR_PTR(-ENODEV) when debugfs is disabled so that any code checking for NULL pretends it is a valid pointer, but that code is only allowed to pass this pointer into other debugfs functions that are also stubbed out and never dereference it. Arnd