Linux-Modules Archive on lore.kernel.org
 help / Atom feed
* [PATCH v3.1] firmware: clean up filesystem load exit path
@ 2016-02-04 21:15 Kees Cook
  2016-02-04 22:01 ` Luis R. Rodriguez
  0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2016-02-04 21:15 UTC (permalink / raw)
  To: Mimi Zohar
  Cc: Luis R. Rodriguez, Josh Boyer, David Howells, linux-kernel,
	David Woodhouse, Dmitry Torokhov, Dmitry Kasatkin,
	Eric Biederman, Rusty Russell, linux-security-module, kexec,
	linux-modules

This makes the error and success paths more readable while trying to
load firmware from the filesystem.

Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Josh Boyer <jwboyer@fedoraproject.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Luis R. Rodriguez <mcgrof@kernel.org>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
---
Suggested as an alternative to "[PATCH v3 06/22] firmware: fold successful fw read early"
---
 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 62e052b50aa9..484afbd783f8 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -352,19 +352,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;
 }
-- 
2.6.3


-- 
Kees Cook
Chrome OS & Brillo Security

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3.1] firmware: clean up filesystem load exit path
  2016-02-04 21:15 [PATCH v3.1] firmware: clean up filesystem load exit path Kees Cook
@ 2016-02-04 22:01 ` Luis R. Rodriguez
  2016-02-04 23:53   ` Mimi Zohar
  0 siblings, 1 reply; 3+ messages in thread
From: Luis R. Rodriguez @ 2016-02-04 22:01 UTC (permalink / raw)
  To: Kees Cook
  Cc: Mimi Zohar, Luis R. Rodriguez, Josh Boyer, David Howells,
	linux-kernel, David Woodhouse, Dmitry Torokhov, Dmitry Kasatkin,
	Eric Biederman, Rusty Russell, linux-security-module, kexec,
	linux-modules

On Thu, Feb 04, 2016 at 01:15:02PM -0800, Kees Cook wrote:
> This makes the error and success paths more readable while trying to
> load firmware from the filesystem.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Cc: Josh Boyer <jwboyer@fedoraproject.org>
> Cc: David Howells <dhowells@redhat.com>
> Cc: Luis R. Rodriguez <mcgrof@kernel.org>
> Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>

Thanks,

Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>

> ---
> Suggested as an alternative to "[PATCH v3 06/22] firmware: fold successful fw read early"

Mimi, feel free to pick up as a replacement in your series.

  Luis

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v3.1] firmware: clean up filesystem load exit path
  2016-02-04 22:01 ` Luis R. Rodriguez
@ 2016-02-04 23:53   ` Mimi Zohar
  0 siblings, 0 replies; 3+ messages in thread
From: Mimi Zohar @ 2016-02-04 23:53 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Kees Cook, Luis R. Rodriguez, Josh Boyer, David Howells,
	linux-kernel, David Woodhouse, Dmitry Torokhov, Dmitry Kasatkin,
	Eric Biederman, Rusty Russell, linux-security-module, kexec,
	linux-modules

On Thu, 2016-02-04 at 23:01 +0100, Luis R. Rodriguez wrote:
> On Thu, Feb 04, 2016 at 01:15:02PM -0800, Kees Cook wrote:
> > This makes the error and success paths more readable while trying to
> > load firmware from the filesystem.
> >
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > Cc: Josh Boyer <jwboyer@fedoraproject.org>
> > Cc: David Howells <dhowells@redhat.com>
> > Cc: Luis R. Rodriguez <mcgrof@kernel.org>
> > Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
> 
> Thanks,
> 
> Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>
> 
> > ---
> > Suggested as an alternative to "[PATCH v3 06/22] firmware: fold successful fw read early"
> 
> Mimi, feel free to pick up as a replacement in your series.

Ok, thanks!

Mimi


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-04 21:15 [PATCH v3.1] firmware: clean up filesystem load exit path Kees Cook
2016-02-04 22:01 ` Luis R. Rodriguez
2016-02-04 23:53   ` Mimi Zohar

Linux-Modules Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-modules/0 linux-modules/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-modules linux-modules/ https://lore.kernel.org/linux-modules \
		linux-modules@vger.kernel.org linux-modules@archiver.kernel.org
	public-inbox-index linux-modules


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-modules


AGPL code for this site: git clone https://public-inbox.org/ public-inbox