lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri,  5 Mar 2010 07:46:00 -0300
From:	André Goddard Rosa <andre.goddard@...il.com>
To:	Greg Kroah-Hartman <gregkh@...e.de>, Alex Chiang <achiang@...com>,
	Kenji Kaneshige <kaneshige.kenji@...fujitsu.com>,
	Serge Hallyn <serue@...ibm.com>, Tejun Heo <tj@...nel.org>,
	linux-kernel@...r.kernel.org
Cc:	André Goddard Rosa <andre.goddard@...il.com>
Subject: [PATCH] sysfs/file: move NULL checks to where they make sense and can occur

... avoiding checking for NULL 2 times in a row when we already have a page.

It decreases code size:
text    data     bss     dec     hex filename
4246      48    4136    8430    20ee fs/sysfs/file-BEFORE.o
4214      48    4136    8398    20ce fs/sysfs/file-AFTER.o

Signed-off-by: André Goddard Rosa <andre.goddard@...il.com>
---
 fs/sysfs/file.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index dc30d9e..962b190 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -79,10 +79,11 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
 	int ret = 0;
 	ssize_t count;
 
-	if (!buffer->page)
-		buffer->page = (char *) get_zeroed_page(GFP_KERNEL);
-	if (!buffer->page)
-		return -ENOMEM;
+	if (!buffer->page) {
+		buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
+		if (!buffer->page)
+			return -ENOMEM;
+	}
 
 	/* need attr_sd for attr and ops, its parent for kobj */
 	if (!sysfs_get_active_two(attr_sd))
@@ -167,10 +168,11 @@ fill_write_buffer(struct sysfs_buffer * buffer, const char __user * buf, size_t
 {
 	int error;
 
-	if (!buffer->page)
+	if (!buffer->page) {
 		buffer->page = (char *)get_zeroed_page(GFP_KERNEL);
-	if (!buffer->page)
-		return -ENOMEM;
+		if (!buffer->page)
+			return -ENOMEM;
+	}
 
 	if (count >= PAGE_SIZE)
 		count = PAGE_SIZE - 1;
-- 
1.7.0.1.164.gbe2f

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists