Skip to content

Commit

Permalink
cifs: fix a possible null pointer deref in decode_ascii_ssetup
Browse files Browse the repository at this point in the history
When kzalloc fails, we will end up doing NULL pointer derefrence

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Signed-off-by: Steve French <smfrench@gmail.com>
  • Loading branch information
Namjae Jeon authored and Steve French committed Aug 21, 2014
1 parent 2bb93d2 commit 27b7edc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/cifs/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,11 @@ static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft,
kfree(ses->serverOS);

ses->serverOS = kzalloc(len + 1, GFP_KERNEL);
if (ses->serverOS)
if (ses->serverOS) {
strncpy(ses->serverOS, bcc_ptr, len);
if (strncmp(ses->serverOS, "OS/2", 4) == 0)
cifs_dbg(FYI, "OS/2 server\n");
if (strncmp(ses->serverOS, "OS/2", 4) == 0)
cifs_dbg(FYI, "OS/2 server\n");
}

bcc_ptr += len + 1;
bleft -= len + 1;
Expand Down

0 comments on commit 27b7edc

Please sign in to comment.