Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753813AbbELUcE (ORCPT ); Tue, 12 May 2015 16:32:04 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:37234 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753610AbbELUb7 (ORCPT ); Tue, 12 May 2015 16:31:59 -0400 MIME-Version: 1.0 In-Reply-To: <1431455457-25322-2-git-send-email-mcgrof@do-not-panic.com> References: <1431455457-25322-1-git-send-email-mcgrof@do-not-panic.com> <1431455457-25322-2-git-send-email-mcgrof@do-not-panic.com> Date: Tue, 12 May 2015 13:31:58 -0700 X-Google-Sender-Auth: MQdK1j9yb1v1-psXiNlJB-VB1mI Message-ID: Subject: Re: [PATCH v2 1/5] firmware: fix __getname() missing failure check From: Linus Torvalds To: "Luis R. Rodriguez" Cc: Ming Lei , Rusty Russell , David Howells , Seth Forshee , Linux Kernel Mailing List , Paul Bolle , Linux Wireless List , "Luis R. Rodriguez" , Kyle McMartin Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1142 Lines: 37 On Tue, May 12, 2015 at 11:30 AM, Luis R. Rodriguez wrote: > + > + path = __getname(); > + if (unlikely(!path)) > + return PTR_ERR(path); This makes no sense. PTR_ERR() on NULL is an insane operation. It's a very non-intuitive and misleading way of writing "0". So not only is that "return 0;", that's not likely what you want _anyway_. If you intended to return an error, you should just have done so, eg if (unlikely(!path)) return -ENOMEM; which actually does something sane, and is more readable. PTR_ERR() is for when you get an error pointer, so a sequence like if (IS_ERR(ptr)) return PTR_ERR(ptr); is sensible (it checks whether the ptr has an error value in it, and then returns the integer error value of the pointer). But for a NULL pointer? No. Linus -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/