diff options
author | Steve French <sfrench@us.ibm.com> | 2006-06-26 00:22:36 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-06-26 00:22:36 -0400 |
commit | cd49b492fe3fef0b6348f18001f0d73f2577eb01 (patch) | |
tree | 09102af7aee4eb73a233354b3555ae0876370609 | |
parent | f90f00a358fe887fe5c3454897521064bdace7cc (diff) |
[CIFS] remove some redundant null pointer checks
some of them pointed out by Dave Jones
Signed-off-by: Steve French <sfrench@us.ibm.com>
-rw-r--r-- | fs/cifs/connect.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 01608bb4d673..c0f98ddea88c 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -2173,8 +2173,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2173 | if (remaining_words > 0) { | 2173 | if (remaining_words > 0) { |
2174 | len = UniStrnlen((wchar_t *)bcc_ptr, | 2174 | len = UniStrnlen((wchar_t *)bcc_ptr, |
2175 | remaining_words-1); | 2175 | remaining_words-1); |
2176 | if(ses->serverNOS) | 2176 | kfree(ses->serverNOS); |
2177 | kfree(ses->serverNOS); | ||
2178 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); | 2177 | ses->serverNOS = kzalloc(2 * (len + 1),GFP_KERNEL); |
2179 | if(ses->serverNOS == NULL) | 2178 | if(ses->serverNOS == NULL) |
2180 | goto sesssetup_nomem; | 2179 | goto sesssetup_nomem; |
@@ -2214,12 +2213,10 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2214 | /* if these kcallocs fail not much we | 2213 | /* if these kcallocs fail not much we |
2215 | can do, but better to not fail the | 2214 | can do, but better to not fail the |
2216 | sesssetup itself */ | 2215 | sesssetup itself */ |
2217 | if(ses->serverDomain) | 2216 | kfree(ses->serverDomain); |
2218 | kfree(ses->serverDomain); | ||
2219 | ses->serverDomain = | 2217 | ses->serverDomain = |
2220 | kzalloc(2, GFP_KERNEL); | 2218 | kzalloc(2, GFP_KERNEL); |
2221 | if(ses->serverNOS) | 2219 | kfree(ses->serverNOS); |
2222 | kfree(ses->serverNOS); | ||
2223 | ses->serverNOS = | 2220 | ses->serverNOS = |
2224 | kzalloc(2, GFP_KERNEL); | 2221 | kzalloc(2, GFP_KERNEL); |
2225 | } | 2222 | } |
@@ -2228,8 +2225,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2228 | if (((long) bcc_ptr + len) - (long) | 2225 | if (((long) bcc_ptr + len) - (long) |
2229 | pByteArea(smb_buffer_response) | 2226 | pByteArea(smb_buffer_response) |
2230 | <= BCC(smb_buffer_response)) { | 2227 | <= BCC(smb_buffer_response)) { |
2231 | if(ses->serverOS) | 2228 | kfree(ses->serverOS); |
2232 | kfree(ses->serverOS); | ||
2233 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); | 2229 | ses->serverOS = kzalloc(len + 1,GFP_KERNEL); |
2234 | if(ses->serverOS == NULL) | 2230 | if(ses->serverOS == NULL) |
2235 | goto sesssetup_nomem; | 2231 | goto sesssetup_nomem; |
@@ -2240,8 +2236,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2240 | bcc_ptr++; | 2236 | bcc_ptr++; |
2241 | 2237 | ||
2242 | len = strnlen(bcc_ptr, 1024); | 2238 | len = strnlen(bcc_ptr, 1024); |
2243 | if(ses->serverNOS) | 2239 | kfree(ses->serverNOS); |
2244 | kfree(ses->serverNOS); | ||
2245 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); | 2240 | ses->serverNOS = kzalloc(len + 1,GFP_KERNEL); |
2246 | if(ses->serverNOS == NULL) | 2241 | if(ses->serverNOS == NULL) |
2247 | goto sesssetup_nomem; | 2242 | goto sesssetup_nomem; |
@@ -2508,8 +2503,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2508 | bcc_ptr, | 2503 | bcc_ptr, |
2509 | remaining_words | 2504 | remaining_words |
2510 | - 1); | 2505 | - 1); |
2511 | if(ses->serverNOS) | 2506 | kfree(ses->serverNOS); |
2512 | kfree(ses->serverNOS); | ||
2513 | ses->serverNOS = | 2507 | ses->serverNOS = |
2514 | kzalloc(2 * (len + 1), | 2508 | kzalloc(2 * (len + 1), |
2515 | GFP_KERNEL); | 2509 | GFP_KERNEL); |
@@ -2527,8 +2521,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2527 | if (remaining_words > 0) { | 2521 | if (remaining_words > 0) { |
2528 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); | 2522 | len = UniStrnlen((wchar_t *) bcc_ptr, remaining_words); |
2529 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ | 2523 | /* last string is not always null terminated (for e.g. for Windows XP & 2000) */ |
2530 | if(ses->serverDomain) | 2524 | kfree(ses->serverDomain); |
2531 | kfree(ses->serverDomain); | ||
2532 | ses->serverDomain = | 2525 | ses->serverDomain = |
2533 | kzalloc(2 * | 2526 | kzalloc(2 * |
2534 | (len + | 2527 | (len + |
@@ -2547,19 +2540,16 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2547 | = 0; | 2540 | = 0; |
2548 | } /* else no more room so create dummy domain string */ | 2541 | } /* else no more room so create dummy domain string */ |
2549 | else { | 2542 | else { |
2550 | if(ses->serverDomain) | 2543 | kfree(ses->serverDomain); |
2551 | kfree(ses->serverDomain); | ||
2552 | ses->serverDomain = | 2544 | ses->serverDomain = |
2553 | kzalloc(2, | 2545 | kzalloc(2, |
2554 | GFP_KERNEL); | 2546 | GFP_KERNEL); |
2555 | } | 2547 | } |
2556 | } else { /* no room so create dummy domain and NOS string */ | 2548 | } else { /* no room so create dummy domain and NOS string */ |
2557 | if(ses->serverDomain); | 2549 | kfree(ses->serverDomain); |
2558 | kfree(ses->serverDomain); | ||
2559 | ses->serverDomain = | 2550 | ses->serverDomain = |
2560 | kzalloc(2, GFP_KERNEL); | 2551 | kzalloc(2, GFP_KERNEL); |
2561 | if(ses->serverNOS) | 2552 | kfree(ses->serverNOS); |
2562 | kfree(ses->serverNOS); | ||
2563 | ses->serverNOS = | 2553 | ses->serverNOS = |
2564 | kzalloc(2, GFP_KERNEL); | 2554 | kzalloc(2, GFP_KERNEL); |
2565 | } | 2555 | } |
@@ -2581,8 +2571,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2581 | bcc_ptr++; | 2571 | bcc_ptr++; |
2582 | 2572 | ||
2583 | len = strnlen(bcc_ptr, 1024); | 2573 | len = strnlen(bcc_ptr, 1024); |
2584 | if(ses->serverNOS) | 2574 | kfree(ses->serverNOS); |
2585 | kfree(ses->serverNOS); | ||
2586 | ses->serverNOS = | 2575 | ses->serverNOS = |
2587 | kzalloc(len + 1, | 2576 | kzalloc(len + 1, |
2588 | GFP_KERNEL); | 2577 | GFP_KERNEL); |
@@ -2592,8 +2581,7 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid, | |||
2592 | bcc_ptr++; | 2581 | bcc_ptr++; |
2593 | 2582 | ||
2594 | len = strnlen(bcc_ptr, 1024); | 2583 | len = strnlen(bcc_ptr, 1024); |
2595 | if(ses->serverDomain) | 2584 | kfree(ses->serverDomain); |
2596 | kfree(ses->serverDomain); | ||
2597 | ses->serverDomain = | 2585 | ses->serverDomain = |
2598 | kzalloc(len + 1, | 2586 | kzalloc(len + 1, |
2599 | GFP_KERNEL); | 2587 | GFP_KERNEL); |
@@ -2915,8 +2903,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2915 | bcc_ptr, | 2903 | bcc_ptr, |
2916 | remaining_words | 2904 | remaining_words |
2917 | - 1); | 2905 | - 1); |
2918 | if(ses->serverNOS) | 2906 | kfree(ses->serverNOS); |
2919 | kfree(ses->serverNOS); | ||
2920 | ses->serverNOS = | 2907 | ses->serverNOS = |
2921 | kzalloc(2 * (len + 1), | 2908 | kzalloc(2 * (len + 1), |
2922 | GFP_KERNEL); | 2909 | GFP_KERNEL); |
@@ -2969,8 +2956,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2969 | if(ses->serverDomain) | 2956 | if(ses->serverDomain) |
2970 | kfree(ses->serverDomain); | 2957 | kfree(ses->serverDomain); |
2971 | ses->serverDomain = kzalloc(2, GFP_KERNEL); | 2958 | ses->serverDomain = kzalloc(2, GFP_KERNEL); |
2972 | if(ses->serverNOS) | 2959 | kfree(ses->serverNOS); |
2973 | kfree(ses->serverNOS); | ||
2974 | ses->serverNOS = kzalloc(2, GFP_KERNEL); | 2960 | ses->serverNOS = kzalloc(2, GFP_KERNEL); |
2975 | } | 2961 | } |
2976 | } else { /* ASCII */ | 2962 | } else { /* ASCII */ |
@@ -2988,8 +2974,7 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2988 | bcc_ptr++; | 2974 | bcc_ptr++; |
2989 | 2975 | ||
2990 | len = strnlen(bcc_ptr, 1024); | 2976 | len = strnlen(bcc_ptr, 1024); |
2991 | if(ses->serverNOS) | 2977 | kfree(ses->serverNOS); |
2992 | kfree(ses->serverNOS); | ||
2993 | ses->serverNOS = kzalloc(len+1,GFP_KERNEL); | 2978 | ses->serverNOS = kzalloc(len+1,GFP_KERNEL); |
2994 | strncpy(ses->serverNOS, bcc_ptr, len); | 2979 | strncpy(ses->serverNOS, bcc_ptr, len); |
2995 | bcc_ptr += len; | 2980 | bcc_ptr += len; |