Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757028Ab3AOIol (ORCPT ); Tue, 15 Jan 2013 03:44:41 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:46251 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757001Ab3AOIoi (ORCPT ); Tue, 15 Jan 2013 03:44:38 -0500 From: Luciano Coelho To: CC: , , Subject: [PATCH] firmware: make sure the fw file size is not 0 Date: Tue, 15 Jan 2013 10:43:43 +0200 Message-ID: <1358239423-9884-1-git-send-email-coelho@ti.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the requested firmware file size is 0 bytes in the filesytem, we will try to vmalloc(0), which causes a warning: [37834.750274] vmalloc: allocation failure: 0 bytes [37834.756347] kworker/1:1: page allocation failure: order:0, mode:0xd2 [37834.763214] [] (unwind_backtrace+0x0/0x13c) from [] (dump_stack+0x20/0x24) [37834.772430] [] (dump_stack+0x20/0x24) from [] (warn_alloc_failed+0xc8/0x120) [37834.781799] [] (warn_alloc_failed+0xc8/0x120) from [] (__vmalloc_node_range+0x16) [37834.792663] [] (__vmalloc_node_range+0x164/0x208) from [] (__vmalloc_node+0x4c/0) [37834.802703] [] (__vmalloc_node+0x4c/0x58) from [] (vmalloc+0x38/0x44) [37834.811401] [] (vmalloc+0x38/0x44) from [] (_request_firmware_load+0x220/0x6b0) [37834.820983] [] (_request_firmware_load+0x220/0x6b0) from [] (request_firmware+0x) [37834.831451] [] (request_firmware+0x64/0xc8) from [] (wl18xx_setup+0xb4/0x570 [wl) [37834.841918] [] (wl18xx_setup+0xb4/0x570 [wl18xx]) from [] (wlcore_nvs_cb+0x64/0x) [37834.852844] [] (wlcore_nvs_cb+0x64/0x9f8 [wlcore]) from [] (request_firmware_wor) [37834.864227] [] (request_firmware_work_func+0x94/0x100) from [] (process_one_work) [37834.875122] [] (process_one_work+0x1d0/0x750) from [] (worker_thread+0x184/0x4ac) [37834.884918] [] (worker_thread+0x184/0x4ac) from [] (kthread+0xb4/0xc0) [37834.893707] [] (kthread+0xb4/0xc0) from [] (ret_from_fork+0x14/0x20) To fix this, check whether the file size is less than or equal to zero in fw_read_file_contents(). Cc: stable [3.7] Signed-off-by: Luciano Coelho --- drivers/base/firmware_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index d814603..b392b35 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -305,7 +305,7 @@ static bool fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf char *buf; size = fw_file_size(file); - if (size < 0) + if (size <= 0) return false; buf = vmalloc(size); if (!buf) -- 1.7.10.4