Skip to contentSkip to conversation

fs: cifs: check kmalloc() result

PATCH Applied Kulikov Vasiliy 4 participants 4 messages Jul 16, 2010 – Jul 19, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 10/15 fs: cifs: check kmalloc() result

If kmalloc() fails exit with -ENOMEM.

---
 fs/cifs/readdir.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
fs/cifs/readdir.c +5 -0
index daf1753..d5e591f 100644
@@ -847,6 +847,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
 		end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
 
 		tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
+		if (tmp_buf = NULL) {
+			rc = -ENOMEM;
+			break;
+		}
+
 		for (i = 0; (i < num_to_fill) && (rc = 0); i++) {
 			if (current_entry = NULL) {
 				/* evaluate whether this case is an error */
Signature · 1 line
1.7.0.4
Acked-by on v1 10/15
#1 lore raw
Quoted 1 line · Kulikov Vasiliy

If kmalloc() fails exit with -ENOMEM.

Looks good to me. Add my ack if you want it.

Quoted 1 line
Quoted 20 lines
---
 fs/cifs/readdir.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
fs/cifs/readdir.c +5 -0
index daf1753..d5e591f 100644
@@ -847,6 +847,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
 		end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
 
 		tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
+		if (tmp_buf = NULL) {
+			rc = -ENOMEM;
+			break;
+		}
+
 		for (i = 0; (i < num_to_fill) && (rc = 0); i++) {
 			if (current_entry = NULL) {
 				/* evaluate whether this case is an error */
Signature · 2 lines
Dave Kleikamp
IBM Linux Technology Center
Acked-by
#2 lore raw
Quoted 20 lines · On Fri, 16 Jul 2010 11:35:30 -0500 Dave Kleikamp <[email protected]>…
Quoted 1 line · Kulikov Vasiliy

If kmalloc() fails exit with -ENOMEM.

Looks good to me. Add my ack if you want it.

Quoted 1 line
Quoted 11 lines
---
 fs/cifs/readdir.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
fs/cifs/readdir.c +0 -0
index daf1753..d5e591f 100644
@@ -847,6 +847,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
 		end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
 
Quoted 10 lines

fs/cifs/readdir.c int cifs_readdir(struct file *file, void *direntry, filldir_t filldir) · line 857

Quoted 9 lines
fs/cifs/readdir.c +5 -0
 		tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
+		if (tmp_buf = NULL) {
+			rc = -ENOMEM;
+			break;
+		}
+
 		for (i = 0; (i < num_to_fill) && (rc = 0); i++) {
 			if (current_entry = NULL) {
 				/* evaluate whether this case is an error */

Looks good to me too.

Applied
#3 lore raw
In reply to Kulikov Vasiliy

merged into cifs-2.6.git

Quoted 27 lines · Kulikov Vasiliy

If kmalloc() fails exit with -ENOMEM.

---
 fs/cifs/readdir.c |    5 +++++

 1 files changed, 5 insertions(+), 0 deletions(-)
fs/cifs/readdir.c +5 -1
index daf1753..d5e591f 100644
@@ -847,6 +847,11 @@ int cifs_readdir(struct file *file, void *direntry, filldir_t filldir)
                end_of_smb = cifsFile->srch_inf.ntwrk_buf_start + max_len;
 
                tmp_buf = kmalloc(UNICODE_NAME_MAX, GFP_KERNEL);
+               if (tmp_buf = NULL) {
+                       rc = -ENOMEM;
+                       break;
+               }
+
                for (i = 0; (i < num_to_fill) && (rc = 0); i++) {
                        if (current_entry = NULL) {
                                /* evaluate whether this case is an error */
--

1.7.0.4

Signature · 7 lines
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html