Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933985AbbELVYg (ORCPT ); Tue, 12 May 2015 17:24:36 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:49974 "EHLO out4-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933121AbbELVVN (ORCPT ); Tue, 12 May 2015 17:21:13 -0400 X-Sasl-enc: tn/8eKnlhReKM7uRc/rDSTrOs2uQsb2i3C1AcRZ/DTop 1431465672 Date: Tue, 12 May 2015 14:21:11 -0700 From: Greg KH To: "Luis R. Rodriguez" Cc: ming.lei@canonical.com, rusty@rustcorp.com.au, dhowells@redhat.com, seth.forshee@canonical.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, pebolle@tiscali.nl, linux-wireless@vger.kernel.org, "Luis R. Rodriguez" , Kyle McMartin Subject: Re: [PATCH v2 1/5] firmware: fix __getname() missing failure check Message-ID: <20150512212111.GB10402@kroah.com> References: <1431455457-25322-1-git-send-email-mcgrof@do-not-panic.com> <1431455457-25322-2-git-send-email-mcgrof@do-not-panic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431455457-25322-2-git-send-email-mcgrof@do-not-panic.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2047 Lines: 55 On Tue, May 12, 2015 at 11:30:53AM -0700, Luis R. Rodriguez wrote: > From: "Luis R. Rodriguez" > > The request_firmware*() APIs uses __getname() to iterate > over the list of paths possible for firmware to be found, > the code however never checked for failure on __getname(). > Although *very unlikely*, this can still happen. Add the > missing check. > > There is still no checks on the concatenation of the path > and filename passed, that requires a bit more work and > subsequent patches address this. The commit that introduced > this is abb139e7 ("firmware: teach the kernel to load > firmware files directly from the filesystem"). > > mcgrof@ergon ~/linux (git::firmware-fixes) $ git describe --contains abb139e7 > v3.7-rc1~120 > > Cc: Linus Torvalds > Cc: Ming Lei > Cc: Rusty Russell > Cc: David Howells > Cc: Kyle McMartin > Signed-off-by: Luis R. Rodriguez > --- > drivers/base/firmware_class.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c > index 171841a..bc6c8e6 100644 > --- a/drivers/base/firmware_class.c > +++ b/drivers/base/firmware_class.c > @@ -322,7 +322,11 @@ static int fw_get_filesystem_firmware(struct device *device, > { > int i; > int rc = -ENOENT; > - char *path = __getname(); > + char *path; > + > + path = __getname(); > + if (unlikely(!path)) Please only use likely/unlikely on code paths that actually care about it (i.e. you can measure the difference). Otherwise it is pretty useless, and people have determined that sometimes it is slower as humans get this wrong a lot of time... thanks, greg k-h -- 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/