2010-07-16 16:15:47

by Kulikov Vasiliy

[permalink] [raw]
Subject: [PATCH 10/15] fs: cifs: check kmalloc() result

If kmalloc() fails exit with -ENOMEM.

Signed-off-by: Kulikov Vasiliy <[email protected]>
---
fs/cifs/readdir.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index daf1753..d5e591f 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -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


2010-07-16 16:35:36

by Dave Kleikamp

[permalink] [raw]
Subject: Re: [PATCH 10/15] fs: cifs: check kmalloc() result

On Fri, 2010-07-16 at 20:15 +0400, Kulikov Vasiliy wrote:
> If kmalloc() fails exit with -ENOMEM.

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

> Signed-off-by: Kulikov Vasiliy <[email protected]>

Acked-by: Dave Kleikamp <[email protected]>

> ---
> fs/cifs/readdir.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> index daf1753..d5e591f 100644
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -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 */

--
Dave Kleikamp
IBM Linux Technology Center

2010-07-19 18:50:53

by Jeff Layton

[permalink] [raw]
Subject: Re: [PATCH 10/15] fs: cifs: check kmalloc() result

On Fri, 16 Jul 2010 11:35:30 -0500
Dave Kleikamp <[email protected]> wrote:

> On Fri, 2010-07-16 at 20:15 +0400, Kulikov Vasiliy wrote:
> > If kmalloc() fails exit with -ENOMEM.
>
> Looks good to me. Add my ack if you want it.
>
> > Signed-off-by: Kulikov Vasiliy <[email protected]>
>
> Acked-by: Dave Kleikamp <[email protected]>
>
> > ---
> > fs/cifs/readdir.c | 5 +++++
> > 1 files changed, 5 insertions(+), 0 deletions(-)
> >
> > diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> > index daf1753..d5e591f 100644
> > --- a/fs/cifs/readdir.c
> > +++ b/fs/cifs/readdir.c
> > @@ -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 */
>

Looks good to me too.

Acked-by: Jeff Layton <[email protected]>

2010-07-19 21:58:24

by Steve French

[permalink] [raw]
Subject: Re: [PATCH 10/15] fs: cifs: check kmalloc() result

merged into cifs-2.6.git

On Fri, Jul 16, 2010 at 11:15 AM, Kulikov Vasiliy <[email protected]> wrote:
> If kmalloc() fails exit with -ENOMEM.
>
> Signed-off-by: Kulikov Vasiliy <[email protected]>
> ---
> ?fs/cifs/readdir.c | ? ?5 +++++
> ?1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
> index daf1753..d5e591f 100644
> --- a/fs/cifs/readdir.c
> +++ b/fs/cifs/readdir.c
> @@ -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
>
>



--
Thanks,

Steve