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  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sat, 17 Jan 2015 23:44:49 -0800
From:	Tristan Lelong <tristan@...ong.xyz>
To:	gregkh@...uxfoundation.org
Cc:	oleg.drokin@...el.com, andreas.dilger@...el.com, askb23@...il.com,
	john.hammond@...el.com, gdonald@...il.com, anhlq2110@...il.com,
	fabio.falzoi84@...il.com, oort10@...il.com, agimenez@...valve.es,
	rupran@...server.de, surya.seetharaman9@...il.com,
	Julia.Lawall@...6.fr, joe@...ches.com, a.terekhov@...il.com,
	liang.zhen@...el.com, vthakkar1994@...il.com, amk@...y.com,
	srikrishanmalik@...il.com, rd@...ekdostal.com, bergwolf@...il.com,
	dan.carpenter@...cle.com, paul.gortmaker@...driver.com,
	tapaswenipathak@...il.com, email@...isccphjaeger.info,
	uja.ornl@...il.com, brillianccv@...ox.ru, dmitry.eremin@...el.com,
	HPDD-discuss@...ts.01.org, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org, Tristan Lelong <tristan@...ong.xyz>
Subject: [PATCH] staging: lustre: remove kmalloc from fld_proc_hash_seq_write

This patch simplifies the fld_proc_hash_seq_write function
by removing the dynamic memory allocation.
The longest fh_name used so far in lustre is 4 characters.
We use a 8 bytes variable to be on the safe side.

Signed-off-by: Tristan Lelong <tristan@...ong.xyz>
---
Hi Greg,
 
This patch is a rework of "staging: lustre: fix sparse warning on LPROC_SEQ_FOPS macros" v3.
It applies on top of your latest staging-testing branch.

Regards
---
 drivers/staging/lustre/lustre/fld/lproc_fld.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index 74b4db9..9b26bb5 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -93,17 +93,13 @@ fld_proc_hash_seq_write(struct file *file,
 {
 	struct lu_client_fld *fld;
 	struct lu_fld_hash *hash = NULL;
-	char *name;
+	char fh_name[8];
 	int i;
 
-	if (count > 80)
+	if (count > sizeof(fh_name))
 		return -ENAMETOOLONG;
 
-	name = kmalloc(count, GFP_KERNEL);
-	if (!name)
-		return -ENOMEM;
-
-	if (copy_from_user(name, buffer, count) != 0)
+	if (copy_from_user(fh_name, buffer, count) != 0)
 		return -EFAULT;
 
 	fld = ((struct seq_file *)file->private_data)->private;
@@ -113,7 +109,7 @@ fld_proc_hash_seq_write(struct file *file,
 		if (count != strlen(fld_hash[i].fh_name))
 			continue;
 
-		if (!strncmp(fld_hash[i].fh_name, name, count)) {
+		if (!strncmp(fld_hash[i].fh_name, fh_name, count)) {
 			hash = &fld_hash[i];
 			break;
 		}
@@ -128,7 +124,6 @@ fld_proc_hash_seq_write(struct file *file,
 		       fld->lcf_name, hash->fh_name);
 	}
 
-	kfree(name);
 	return count;
 }
 
-- 
2.1.3

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ