PCI: tegra: Add debugfs support
[firefly-linux-kernel-4.4.55.git] / fs / cifs / smb2pdu.c
index 3802f8c94accdba8e9d62622155a523a2c39b4d4..b0b260dbb19dff021ad124fbad81322f51b8b69e 100644 (file)
@@ -375,7 +375,12 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 
        req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
 
-       memcpy(req->ClientGUID, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
+       /* ClientGUID must be zero for SMB2.02 dialect */
+       if (ses->server->vals->protocol_id == SMB20_PROT_ID)
+               memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE);
+       else
+               memcpy(req->ClientGUID, server->client_guid,
+                       SMB2_CLIENT_GUID_SIZE);
 
        iov[0].iov_base = (char *)req;
        /* 4 for rfc1002 length field */
@@ -478,7 +483,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 
        vneg_inbuf.Capabilities =
                        cpu_to_le32(tcon->ses->server->vals->req_capabilities);
-       memcpy(vneg_inbuf.Guid, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
+       memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
+                                       SMB2_CLIENT_GUID_SIZE);
 
        if (tcon->ses->sign)
                vneg_inbuf.SecurityMode =
@@ -966,6 +972,7 @@ create_durable_buf(void)
        buf->ccontext.NameOffset = cpu_to_le16(offsetof
                                (struct create_durable, Name));
        buf->ccontext.NameLength = cpu_to_le16(4);
+       /* SMB2_CREATE_DURABLE_HANDLE_REQUEST is "DHnQ" */
        buf->Name[0] = 'D';
        buf->Name[1] = 'H';
        buf->Name[2] = 'n';
@@ -990,6 +997,7 @@ create_reconnect_durable_buf(struct cifs_fid *fid)
        buf->ccontext.NameLength = cpu_to_le16(4);
        buf->Data.Fid.PersistentFileId = fid->persistent_fid;
        buf->Data.Fid.VolatileFileId = fid->volatile_fid;
+       /* SMB2_CREATE_DURABLE_HANDLE_RECONNECT is "DHnC" */
        buf->Name[0] = 'D';
        buf->Name[1] = 'H';
        buf->Name[2] = 'n';
@@ -1089,6 +1097,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
        int rc = 0;
        unsigned int num_iovecs = 2;
        __u32 file_attributes = 0;
+       char *dhc_buf = NULL, *lc_buf = NULL;
 
        cifs_dbg(FYI, "create/open\n");
 
@@ -1155,6 +1164,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                        kfree(copy_path);
                        return rc;
                }
+               lc_buf = iov[num_iovecs-1].iov_base;
        }
 
        if (*oplock == SMB2_OPLOCK_LEVEL_BATCH) {
@@ -1169,9 +1179,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                if (rc) {
                        cifs_small_buf_release(req);
                        kfree(copy_path);
-                       kfree(iov[num_iovecs-1].iov_base);
+                       kfree(lc_buf);
                        return rc;
                }
+               dhc_buf = iov[num_iovecs-1].iov_base;
        }
 
        rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0);
@@ -1203,6 +1214,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
                *oplock = rsp->OplockLevel;
 creat_exit:
        kfree(copy_path);
+       kfree(lc_buf);
+       kfree(dhc_buf);
        free_rsp_buf(resp_buftype, rsp);
        return rc;
 }