Skip to content

Commit

Permalink
SUNRPC: Refactor gssx_dec_option_array() to kill uninitialized warning
Browse files Browse the repository at this point in the history
net/sunrpc/auth_gss/gss_rpc_xdr.c: In function ‘gssx_dec_option_array’:
net/sunrpc/auth_gss/gss_rpc_xdr.c:258: warning: ‘creds’ may be used uninitialized in this function

Return early if count is zero, to make it clearer to the compiler (and the
casual reviewer) that no more processing is done.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Geert Uytterhoeven authored and J. Bruce Fields committed May 6, 2013
1 parent 9f415eb commit 9fd40c5
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions net/sunrpc/auth_gss/gss_rpc_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,25 +264,27 @@ static int gssx_dec_option_array(struct xdr_stream *xdr,
if (unlikely(p == NULL))
return -ENOSPC;
count = be32_to_cpup(p++);
if (count != 0) {
/* we recognize only 1 currently: CREDS_VALUE */
oa->count = 1;
if (!count)
return 0;

oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
if (!oa->data)
return -ENOMEM;
/* we recognize only 1 currently: CREDS_VALUE */
oa->count = 1;

creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
if (!creds) {
kfree(oa->data);
return -ENOMEM;
}
oa->data = kmalloc(sizeof(struct gssx_option), GFP_KERNEL);
if (!oa->data)
return -ENOMEM;

oa->data[0].option.data = CREDS_VALUE;
oa->data[0].option.len = sizeof(CREDS_VALUE);
oa->data[0].value.data = (void *)creds;
oa->data[0].value.len = 0;
creds = kmalloc(sizeof(struct svc_cred), GFP_KERNEL);
if (!creds) {
kfree(oa->data);
return -ENOMEM;
}

oa->data[0].option.data = CREDS_VALUE;
oa->data[0].option.len = sizeof(CREDS_VALUE);
oa->data[0].value.data = (void *)creds;
oa->data[0].value.len = 0;

for (i = 0; i < count; i++) {
gssx_buffer dummy = { 0, NULL };
u32 length;
Expand Down

0 comments on commit 9fd40c5

Please sign in to comment.