]> err.no Git - linux-2.6/blobdiff - fs/cifs/cifssmb.c
Merge branches 'x86/numa-fixes', 'x86/apic', 'x86/apm', 'x86/bitops', 'x86/build...
[linux-2.6] / fs / cifs / cifssmb.c
index 6f8ed93a4ae8671fbbffbb7d761e5742623cc06a..4511b708f0f312d57677e2947276c2063f142446 100644 (file)
@@ -107,6 +107,7 @@ cifs_strncpy_to_host(char **dst, const char *src, const int maxlen,
                strncpy(*dst, src, plen);
        }
        (*dst)[plen] = 0;
+       (*dst)[plen+1] = 0; /* harmless for ASCII case, needed for Unicode */
        return 0;
 
 cifs_strncpy_to_host_ErrExit:
@@ -1727,7 +1728,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
 {
        int rc = 0;
        LOCK_REQ *pSMB = NULL;
-       LOCK_RSP *pSMBr = NULL;
+/*     LOCK_RSP *pSMBr = NULL; */ /* No response data other than rc to parse */
        int bytes_returned;
        int timeout = 0;
        __u16 count;
@@ -1738,8 +1739,6 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
        if (rc)
                return rc;
 
-       pSMBr = (LOCK_RSP *)pSMB; /* BB removeme BB */
-
        if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
                timeout = CIFS_ASYNC_OP; /* no response expected */
                pSMB->Timeout = 0;
@@ -1773,7 +1772,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
 
        if (waitFlag) {
                rc = SendReceiveBlockingLock(xid, tcon, (struct smb_hdr *) pSMB,
-                       (struct smb_hdr *) pSMBr, &bytes_returned);
+                       (struct smb_hdr *) pSMB, &bytes_returned);
                cifs_small_buf_release(pSMB);
        } else {
                rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *)pSMB,
@@ -2158,8 +2157,7 @@ copyRetry:
                cFYI(1, ("Send error in copy = %d with %d files copied",
                        rc, le16_to_cpu(pSMBr->CopyCount)));
        }
-       if (pSMB)
-               cifs_buf_release(pSMB);
+       cifs_buf_release(pSMB);
 
        if (rc == -EAGAIN)
                goto copyRetry;
@@ -2248,8 +2246,7 @@ createSymLinkRetry:
        if (rc)
                cFYI(1, ("Send error in SetPathInfo create symlink = %d", rc));
 
-       if (pSMB)
-               cifs_buf_release(pSMB);
+       cifs_buf_release(pSMB);
 
        if (rc == -EAGAIN)
                goto createSymLinkRetry;
@@ -3907,7 +3904,7 @@ GetInodeNumOut:
  *     on failure - errno
  */
 static int
-parse_DFS_REFERRALS(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
+parse_DFS_referrals(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
                unsigned int *num_of_nodes,
                struct dfs_info3_param **target_nodes,
                const struct nls_table *nls_codepage)
@@ -3924,15 +3921,15 @@ parse_DFS_REFERRALS(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
                cERROR(1, ("num_referrals: must be at least > 0,"
                        "but we get num_referrals = %d\n", *num_of_nodes));
                rc = -EINVAL;
-               goto parse_DFS_REFERRALS_exit;
+               goto parse_DFS_referrals_exit;
        }
 
        ref = (struct dfs_referral_level_3 *) &(pSMBr->referrals);
-       if (ref->VersionNumber != 3) {
+       if (ref->VersionNumber != cpu_to_le16(3)) {
                cERROR(1, ("Referrals of V%d version are not supported,"
-                       "should be V3", ref->VersionNumber));
+                       "should be V3", le16_to_cpu(ref->VersionNumber)));
                rc = -EINVAL;
-               goto parse_DFS_REFERRALS_exit;
+               goto parse_DFS_referrals_exit;
        }
 
        /* get the upper boundary of the resp buffer */
@@ -3948,7 +3945,7 @@ parse_DFS_REFERRALS(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
        if (*target_nodes == NULL) {
                cERROR(1, ("Failed to allocate buffer for target_nodes\n"));
                rc = -ENOMEM;
-               goto parse_DFS_REFERRALS_exit;
+               goto parse_DFS_referrals_exit;
        }
 
        /* collect neccessary data from referrals */
@@ -3968,7 +3965,7 @@ parse_DFS_REFERRALS(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
                rc = cifs_strncpy_to_host(&(node->path_name), temp,
                                        max_len, is_unicode, nls_codepage);
                if (rc)
-                       goto parse_DFS_REFERRALS_exit;
+                       goto parse_DFS_referrals_exit;
 
                /* copy link target UNC */
                temp = (char *)ref + le16_to_cpu(ref->NetworkAddressOffset);
@@ -3976,12 +3973,12 @@ parse_DFS_REFERRALS(TRANSACTION2_GET_DFS_REFER_RSP *pSMBr,
                rc = cifs_strncpy_to_host(&(node->node_name), temp,
                                        max_len, is_unicode, nls_codepage);
                if (rc)
-                       goto parse_DFS_REFERRALS_exit;
+                       goto parse_DFS_referrals_exit;
 
-               ref += ref->Size;
+               ref += le16_to_cpu(ref->Size);
        }
 
-parse_DFS_REFERRALS_exit:
+parse_DFS_referrals_exit:
        if (rc) {
                free_dfs_info_array(*target_nodes, *num_of_nodes);
                *target_nodes = NULL;
@@ -4090,12 +4087,11 @@ getDFSRetry:
                                le16_to_cpu(pSMBr->t2.DataOffset)));
 
        /* parse returned result into more usable form */
-       rc = parse_DFS_REFERRALS(pSMBr, num_of_nodes,
+       rc = parse_DFS_referrals(pSMBr, num_of_nodes,
                                 target_nodes, nls_codepage);
 
 GetDFSRefExit:
-       if (pSMB)
-               cifs_buf_release(pSMB);
+       cifs_buf_release(pSMB);
 
        if (rc == -EAGAIN)
                goto getDFSRetry;
@@ -5116,8 +5112,7 @@ setPermsRetry:
        if (rc)
                cFYI(1, ("SetPathInfo (perms) returned %d", rc));
 
-       if (pSMB)
-               cifs_buf_release(pSMB);
+       cifs_buf_release(pSMB);
        if (rc == -EAGAIN)
                goto setPermsRetry;
        return rc;
@@ -5339,8 +5334,7 @@ QAllEAsRetry:
                        }
                }
        }
-       if (pSMB)
-               cifs_buf_release(pSMB);
+       cifs_buf_release(pSMB);
        if (rc == -EAGAIN)
                goto QAllEAsRetry;
 
@@ -5489,8 +5483,7 @@ QEARetry:
                        }
                }
        }
-       if (pSMB)
-               cifs_buf_release(pSMB);
+       cifs_buf_release(pSMB);
        if (rc == -EAGAIN)
                goto QEARetry;