diff options
author | Steve French <sfrench@us.ibm.com> | 2008-12-11 12:26:54 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2008-12-25 21:29:12 -0500 |
commit | 2b2bdfba7a3679f67b7c3aca4a4b08b24bb675a8 (patch) | |
tree | aad732c85a51b26f8a8b54fdeecc5b54025671fa /fs/cifs | |
parent | 8e4f2e8a1e5cfa07c5b2731accee0e6eb4c64575 (diff) |
[CIFS] Streamline SendReceive[2] by using "goto out:" in an error condition
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/transport.c | 139 |
1 files changed, 72 insertions, 67 deletions
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 01b3aa5f928b..ca015e60002a 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -619,49 +619,52 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, | |||
619 | cERROR(1, ("Frame too large received. Length: %d Xid: %d", | 619 | cERROR(1, ("Frame too large received. Length: %d Xid: %d", |
620 | receive_len, xid)); | 620 | receive_len, xid)); |
621 | rc = -EIO; | 621 | rc = -EIO; |
622 | } else { /* rcvd frame is ok */ | 622 | goto out; |
623 | if (midQ->resp_buf && | 623 | } |
624 | (midQ->midState == MID_RESPONSE_RECEIVED)) { | ||
625 | 624 | ||
626 | iov[0].iov_base = (char *)midQ->resp_buf; | 625 | /* rcvd frame is ok */ |
627 | if (midQ->largeBuf) | ||
628 | *pRespBufType = CIFS_LARGE_BUFFER; | ||
629 | else | ||
630 | *pRespBufType = CIFS_SMALL_BUFFER; | ||
631 | iov[0].iov_len = receive_len + 4; | ||
632 | 626 | ||
633 | dump_smb(midQ->resp_buf, 80); | 627 | if (midQ->resp_buf && |
634 | /* convert the length into a more usable form */ | 628 | (midQ->midState == MID_RESPONSE_RECEIVED)) { |
635 | if ((receive_len > 24) && | 629 | |
636 | (ses->server->secMode & (SECMODE_SIGN_REQUIRED | | 630 | iov[0].iov_base = (char *)midQ->resp_buf; |
637 | SECMODE_SIGN_ENABLED))) { | 631 | if (midQ->largeBuf) |
638 | rc = cifs_verify_signature(midQ->resp_buf, | 632 | *pRespBufType = CIFS_LARGE_BUFFER; |
633 | else | ||
634 | *pRespBufType = CIFS_SMALL_BUFFER; | ||
635 | iov[0].iov_len = receive_len + 4; | ||
636 | |||
637 | dump_smb(midQ->resp_buf, 80); | ||
638 | /* convert the length into a more usable form */ | ||
639 | if ((receive_len > 24) && | ||
640 | (ses->server->secMode & (SECMODE_SIGN_REQUIRED | | ||
641 | SECMODE_SIGN_ENABLED))) { | ||
642 | rc = cifs_verify_signature(midQ->resp_buf, | ||
639 | &ses->server->mac_signing_key, | 643 | &ses->server->mac_signing_key, |
640 | midQ->sequence_number+1); | 644 | midQ->sequence_number+1); |
641 | if (rc) { | 645 | if (rc) { |
642 | cERROR(1, ("Unexpected SMB signature")); | 646 | cERROR(1, ("Unexpected SMB signature")); |
643 | /* BB FIXME add code to kill session */ | 647 | /* BB FIXME add code to kill session */ |
644 | } | ||
645 | } | 648 | } |
646 | |||
647 | /* BB special case reconnect tid and uid here? */ | ||
648 | rc = map_smb_to_linux_error(midQ->resp_buf, | ||
649 | flags & CIFS_LOG_ERROR); | ||
650 | |||
651 | /* convert ByteCount if necessary */ | ||
652 | if (receive_len >= sizeof(struct smb_hdr) - 4 | ||
653 | /* do not count RFC1001 header */ + | ||
654 | (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ ) | ||
655 | BCC(midQ->resp_buf) = | ||
656 | le16_to_cpu(BCC_LE(midQ->resp_buf)); | ||
657 | if ((flags & CIFS_NO_RESP) == 0) | ||
658 | midQ->resp_buf = NULL; /* mark it so buf will | ||
659 | not be freed by | ||
660 | DeleteMidQEntry */ | ||
661 | } else { | ||
662 | rc = -EIO; | ||
663 | cFYI(1, ("Bad MID state?")); | ||
664 | } | 649 | } |
650 | |||
651 | /* BB special case reconnect tid and uid here? */ | ||
652 | rc = map_smb_to_linux_error(midQ->resp_buf, | ||
653 | flags & CIFS_LOG_ERROR); | ||
654 | |||
655 | /* convert ByteCount if necessary */ | ||
656 | if (receive_len >= sizeof(struct smb_hdr) - 4 | ||
657 | /* do not count RFC1001 header */ + | ||
658 | (2 * midQ->resp_buf->WordCount) + 2 /* bcc */ ) | ||
659 | BCC(midQ->resp_buf) = | ||
660 | le16_to_cpu(BCC_LE(midQ->resp_buf)); | ||
661 | if ((flags & CIFS_NO_RESP) == 0) | ||
662 | midQ->resp_buf = NULL; /* mark it so buf will | ||
663 | not be freed by | ||
664 | DeleteMidQEntry */ | ||
665 | } else { | ||
666 | rc = -EIO; | ||
667 | cFYI(1, ("Bad MID state?")); | ||
665 | } | 668 | } |
666 | 669 | ||
667 | out: | 670 | out: |
@@ -809,43 +812,45 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
809 | cERROR(1, ("Frame too large received. Length: %d Xid: %d", | 812 | cERROR(1, ("Frame too large received. Length: %d Xid: %d", |
810 | receive_len, xid)); | 813 | receive_len, xid)); |
811 | rc = -EIO; | 814 | rc = -EIO; |
812 | } else { /* rcvd frame is ok */ | 815 | goto out; |
813 | 816 | } | |
814 | if (midQ->resp_buf && out_buf | ||
815 | && (midQ->midState == MID_RESPONSE_RECEIVED)) { | ||
816 | out_buf->smb_buf_length = receive_len; | ||
817 | memcpy((char *)out_buf + 4, | ||
818 | (char *)midQ->resp_buf + 4, | ||
819 | receive_len); | ||
820 | 817 | ||
821 | dump_smb(out_buf, 92); | 818 | /* rcvd frame is ok */ |
822 | /* convert the length into a more usable form */ | 819 | |
823 | if ((receive_len > 24) && | 820 | if (midQ->resp_buf && out_buf |
824 | (ses->server->secMode & (SECMODE_SIGN_REQUIRED | | 821 | && (midQ->midState == MID_RESPONSE_RECEIVED)) { |
825 | SECMODE_SIGN_ENABLED))) { | 822 | out_buf->smb_buf_length = receive_len; |
826 | rc = cifs_verify_signature(out_buf, | 823 | memcpy((char *)out_buf + 4, |
824 | (char *)midQ->resp_buf + 4, | ||
825 | receive_len); | ||
826 | |||
827 | dump_smb(out_buf, 92); | ||
828 | /* convert the length into a more usable form */ | ||
829 | if ((receive_len > 24) && | ||
830 | (ses->server->secMode & (SECMODE_SIGN_REQUIRED | | ||
831 | SECMODE_SIGN_ENABLED))) { | ||
832 | rc = cifs_verify_signature(out_buf, | ||
827 | &ses->server->mac_signing_key, | 833 | &ses->server->mac_signing_key, |
828 | midQ->sequence_number+1); | 834 | midQ->sequence_number+1); |
829 | if (rc) { | 835 | if (rc) { |
830 | cERROR(1, ("Unexpected SMB signature")); | 836 | cERROR(1, ("Unexpected SMB signature")); |
831 | /* BB FIXME add code to kill session */ | 837 | /* BB FIXME add code to kill session */ |
832 | } | ||
833 | } | 838 | } |
839 | } | ||
834 | 840 | ||
835 | *pbytes_returned = out_buf->smb_buf_length; | 841 | *pbytes_returned = out_buf->smb_buf_length; |
836 | 842 | ||
837 | /* BB special case reconnect tid and uid here? */ | 843 | /* BB special case reconnect tid and uid here? */ |
838 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); | 844 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); |
839 | 845 | ||
840 | /* convert ByteCount if necessary */ | 846 | /* convert ByteCount if necessary */ |
841 | if (receive_len >= sizeof(struct smb_hdr) - 4 | 847 | if (receive_len >= sizeof(struct smb_hdr) - 4 |
842 | /* do not count RFC1001 header */ + | 848 | /* do not count RFC1001 header */ + |
843 | (2 * out_buf->WordCount) + 2 /* bcc */ ) | 849 | (2 * out_buf->WordCount) + 2 /* bcc */ ) |
844 | BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); | 850 | BCC(out_buf) = le16_to_cpu(BCC_LE(out_buf)); |
845 | } else { | 851 | } else { |
846 | rc = -EIO; | 852 | rc = -EIO; |
847 | cERROR(1, ("Bad MID state?")); | 853 | cERROR(1, ("Bad MID state?")); |
848 | } | ||
849 | } | 854 | } |
850 | 855 | ||
851 | out: | 856 | out: |