diff options
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 58c509e6ac6a..98ec57ff4d98 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -752,6 +752,7 @@ multi_t2_fnd: | |||
752 | } | 752 | } |
753 | write_unlock(&GlobalSMBSeslock); | 753 | write_unlock(&GlobalSMBSeslock); |
754 | 754 | ||
755 | kfree(server->hostname); | ||
755 | kfree(server); | 756 | kfree(server); |
756 | if (length > 0) | 757 | if (length > 0) |
757 | mempool_resize(cifs_req_poolp, length + cifs_min_rcv, | 758 | mempool_resize(cifs_req_poolp, length + cifs_min_rcv, |
@@ -760,6 +761,34 @@ multi_t2_fnd: | |||
760 | return 0; | 761 | return 0; |
761 | } | 762 | } |
762 | 763 | ||
764 | /* extract the host portion of the UNC string */ | ||
765 | static char * | ||
766 | extract_hostname(const char *unc) | ||
767 | { | ||
768 | const char *src; | ||
769 | char *dst, *delim; | ||
770 | unsigned int len; | ||
771 | |||
772 | /* skip double chars at beginning of string */ | ||
773 | /* BB: check validity of these bytes? */ | ||
774 | src = unc + 2; | ||
775 | |||
776 | /* delimiter between hostname and sharename is always '\\' now */ | ||
777 | delim = strchr(src, '\\'); | ||
778 | if (!delim) | ||
779 | return ERR_PTR(-EINVAL); | ||
780 | |||
781 | len = delim - src; | ||
782 | dst = kmalloc((len + 1), GFP_KERNEL); | ||
783 | if (dst == NULL) | ||
784 | return ERR_PTR(-ENOMEM); | ||
785 | |||
786 | memcpy(dst, src, len); | ||
787 | dst[len] = '\0'; | ||
788 | |||
789 | return dst; | ||
790 | } | ||
791 | |||
763 | static int | 792 | static int |
764 | cifs_parse_mount_options(char *options, const char *devname, | 793 | cifs_parse_mount_options(char *options, const char *devname, |
765 | struct smb_vol *vol) | 794 | struct smb_vol *vol) |
@@ -1900,6 +1929,12 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1900 | /* BB Add code for ipv6 case too */ | 1929 | /* BB Add code for ipv6 case too */ |
1901 | srvTcp->ssocket = csocket; | 1930 | srvTcp->ssocket = csocket; |
1902 | srvTcp->protocolType = IPV4; | 1931 | srvTcp->protocolType = IPV4; |
1932 | srvTcp->hostname = extract_hostname(volume_info.UNC); | ||
1933 | if (IS_ERR(srvTcp->hostname)) { | ||
1934 | rc = PTR_ERR(srvTcp->hostname); | ||
1935 | sock_release(csocket); | ||
1936 | goto out; | ||
1937 | } | ||
1903 | init_waitqueue_head(&srvTcp->response_q); | 1938 | init_waitqueue_head(&srvTcp->response_q); |
1904 | init_waitqueue_head(&srvTcp->request_q); | 1939 | init_waitqueue_head(&srvTcp->request_q); |
1905 | INIT_LIST_HEAD(&srvTcp->pending_mid_q); | 1940 | INIT_LIST_HEAD(&srvTcp->pending_mid_q); |
@@ -1914,6 +1949,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1914 | cERROR(1, ("error %d create cifsd thread", rc)); | 1949 | cERROR(1, ("error %d create cifsd thread", rc)); |
1915 | srvTcp->tsk = NULL; | 1950 | srvTcp->tsk = NULL; |
1916 | sock_release(csocket); | 1951 | sock_release(csocket); |
1952 | kfree(srvTcp->hostname); | ||
1917 | goto out; | 1953 | goto out; |
1918 | } | 1954 | } |
1919 | wait_for_completion(&cifsd_complete); | 1955 | wait_for_completion(&cifsd_complete); |