From patchwork Fri Feb 12 18:29:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 8295101 Return-Path: X-Original-To: patchwork-linux-fsdevel@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 E5D939F372 for ; Fri, 12 Feb 2016 18:30:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 262EC2041F for ; Fri, 12 Feb 2016 18:30:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 17078203DA for ; Fri, 12 Feb 2016 18:30:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751956AbcBLSas (ORCPT ); Fri, 12 Feb 2016 13:30:48 -0500 Received: from e28smtp07.in.ibm.com ([125.16.236.7]:33118 "EHLO e28smtp07.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752512AbcBLSaq (ORCPT ); Fri, 12 Feb 2016 13:30:46 -0500 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 13 Feb 2016 00:00:43 +0530 Received: from d28relay03.in.ibm.com (9.184.220.60) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 13 Feb 2016 00:00:41 +0530 X-IBM-Helo: d28relay03.in.ibm.com X-IBM-MailFrom: zohar@linux.vnet.ibm.com X-IBM-RcptTo: linux-fsdevel@vger.kernel.org; linux-modules@vger.kernel.org; linux-security-module@vger.kernel.org Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1CIUeUC7799288; Sat, 13 Feb 2016 00:00:41 +0530 Received: from d28av05.in.ibm.com (localhost [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1CIUX8h031197; Sat, 13 Feb 2016 00:00:40 +0530 Received: from localhost.localdomain.localdomain (dhcp-9-2-55-85.watson.ibm.com [9.2.55.85]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u1CITfXT029331; Sat, 13 Feb 2016 00:00:24 +0530 From: Mimi Zohar To: linux-security-module Cc: Kees Cook , "Luis R. Rodriguez" , kexec@lists.infradead.org, linux-modules@vger.kernel.org, linux-fsdevel@vger.kernel.org, Dmitry Kasatkin , Josh Boyer , David Howells , Mimi Zohar Subject: [PATCH v4 03/19] firmware: clean up filesystem load exit path Date: Fri, 12 Feb 2016 13:29:15 -0500 Message-Id: <1455301771-7703-4-git-send-email-zohar@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1455301771-7703-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1455301771-7703-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 16021218-0025-0000-0000-000009E741B5 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Kees Cook This makes the error and success paths more readable while trying to load firmware from the filesystem. Signed-off-by: Kees Cook Cc: Josh Boyer Cc: David Howells Acked-by: Luis R. Rodriguez Signed-off-by: Mimi Zohar --- drivers/base/firmware_class.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 7bc4ad0..c743a2f 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -361,19 +361,17 @@ static int fw_get_filesystem_firmware(struct device *device, continue; rc = fw_read_file_contents(file, buf); fput(file); - if (rc) + if (rc) { dev_warn(device, "loading %s failed with error %d\n", path, rc); - else - break; - } - __putname(path); - - if (!rc) { + continue; + } dev_dbg(device, "direct-loading %s\n", buf->fw_id); fw_finish_direct_load(device, buf); + break; } + __putname(path); return rc; }