From patchwork Tue May 12 21:49:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 6392011 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9EF759F32E for ; Tue, 12 May 2015 21:54:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BBF25202EC for ; Tue, 12 May 2015 21:54:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB0B0202DD for ; Tue, 12 May 2015 21:54:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933950AbbELVyJ (ORCPT ); Tue, 12 May 2015 17:54:09 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:35110 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932808AbbELVyG (ORCPT ); Tue, 12 May 2015 17:54:06 -0400 Received: by pabtp1 with SMTP id tp1so27568510pab.2; Tue, 12 May 2015 14:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=X3qmkVdOSCiHHTBK8Cjit3jp6NNnvdYPZmnopkSTPE0=; b=b2IPBVc5xBXRECpOnNuOhXZfuBh8IQ+u3iuXPXpf9t3oml4iD0Vdf6U8Du4BmNqKYf xfojtwIq9xV5iMx3pWWN5ML8cvc1H/qUd+SG+4jmL7PiK0ZIugwonKfgfdAc79lMc4D4 jg9cFZi5ZGzL3Z0Onqox+qepzNBDLu5PSq7Kp6Pcmtb13SDdHXjGZlov/5ZJbVBQ0R/m sCd89wNXEy5qndOc/p/4O0NRgx1B97OQ7BzsM/0WTGgHiC58w/uhtcLimEV4SlW9rt6T xHNEQloCu08fPFnfUB3zHFtxm0IzdpUuHG/165eBwK8gCMkwPFgeNy+a5sw3EUrPiBvE lqWQ== X-Received: by 10.68.197.100 with SMTP id it4mr31637123pbc.143.1431467646500; Tue, 12 May 2015 14:54:06 -0700 (PDT) Received: from mcgrof@gmail.com (c-98-234-145-61.hsd1.ca.comcast.net. [98.234.145.61]) by mx.google.com with ESMTPSA id tr6sm17220640pab.4.2015.05.12.14.54.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 May 2015 14:54:05 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Tue, 12 May 2015 14:51:56 -0700 From: "Luis R. Rodriguez" To: ming.lei@canonical.com, rusty@rustcorp.com.au Cc: torvalds@linux-foundation.org, dhowells@redhat.com, seth.forshee@canonical.com, linux-kernel@vger.kernel.org, pebolle@tiscali.nl, linux-wireless@vger.kernel.org, gregkh@linuxfoundation.org, jlee@suse.com, tiwai@suse.de, "Luis R. Rodriguez" , Kyle McMartin Subject: [PATCH v3 1/4] firmware: fix __getname() missing failure check Date: Tue, 12 May 2015 14:49:40 -0700 Message-Id: <1431467383-28540-2-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431467383-28540-1-git-send-email-mcgrof@do-not-panic.com> References: <1431467383-28540-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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..49139a1 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 (!path) + return -ENOMEM; for (i = 0; i < ARRAY_SIZE(fw_path); i++) { struct file *file;