@@ -1514,8 +1514,14 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
cFYI(1, ("Send error in write = %d", rc));
*nbytes = 0;
} else {
- *nbytes = le16_to_cpu(pSMBr->CountHigh);
- *nbytes = (*nbytes) << 16;
+ /*
+ * Some legacy servers (read OS/2) might incorrectly set
+ * CountHigh for normal writes resulting in wrong 'nbytes' value
+ */
+ if (tcon->ses->capabilities & CAP_LARGE_WRITE_X) {
+ *nbytes = le16_to_cpu(pSMBr->CountHigh);
+ *nbytes = (*nbytes) << 16;
+ }
*nbytes += le16_to_cpu(pSMBr->Count);
}
@@ -1602,8 +1608,14 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon,
rc = -EIO;
} else {
WRITE_RSP *pSMBr = (WRITE_RSP *)iov[0].iov_base;
- *nbytes = le16_to_cpu(pSMBr->CountHigh);
- *nbytes = (*nbytes) << 16;
+ /*
+ * Some legacy servers (read OS/2) might incorrectly set
+ * CountHigh for normal writes resulting in wrong 'nbytes' value
+ */
+ if (tcon->ses->capabilities & CAP_LARGE_WRITE_X) {
+ *nbytes = le16_to_cpu(pSMBr->CountHigh);
+ *nbytes = (*nbytes) << 16;
+ }
*nbytes += le16_to_cpu(pSMBr->Count);
}