Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.samba.org/sfrench/cifs-2.6

Pull CIFS fixes from Steve French.

* git://git.samba.org/sfrench/cifs-2.6:
CIFS: Do not kmalloc under the flocks spinlock
cifs: possible memory leak in xattr.

+61 -18
+58 -15
fs/cifs/file.c
··· 920 920 for (lockp = &inode->i_flock; *lockp != NULL; \ 921 921 lockp = &(*lockp)->fl_next) 922 922 923 + struct lock_to_push { 924 + struct list_head llist; 925 + __u64 offset; 926 + __u64 length; 927 + __u32 pid; 928 + __u16 netfid; 929 + __u8 type; 930 + }; 931 + 923 932 static int 924 933 cifs_push_posix_locks(struct cifsFileInfo *cfile) 925 934 { 926 935 struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode); 927 936 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 928 937 struct file_lock *flock, **before; 929 - struct cifsLockInfo *lck, *tmp; 938 + unsigned int count = 0, i = 0; 930 939 int rc = 0, xid, type; 940 + struct list_head locks_to_send, *el; 941 + struct lock_to_push *lck, *tmp; 931 942 __u64 length; 932 - struct list_head locks_to_send; 933 943 934 944 xid = GetXid(); 935 945 ··· 950 940 return rc; 951 941 } 952 942 953 - INIT_LIST_HEAD(&locks_to_send); 954 - 955 943 lock_flocks(); 956 944 cifs_for_each_lock(cfile->dentry->d_inode, before) { 945 + if ((*before)->fl_flags & FL_POSIX) 946 + count++; 947 + } 948 + unlock_flocks(); 949 + 950 + INIT_LIST_HEAD(&locks_to_send); 951 + 952 + /* 953 + * Allocating count locks is enough because no locks can be added to 954 + * the list while we are holding cinode->lock_mutex that protects 955 + * locking operations of this inode. 956 + */ 957 + for (; i < count; i++) { 958 + lck = kmalloc(sizeof(struct lock_to_push), GFP_KERNEL); 959 + if (!lck) { 960 + rc = -ENOMEM; 961 + goto err_out; 962 + } 963 + list_add_tail(&lck->llist, &locks_to_send); 964 + } 965 + 966 + i = 0; 967 + el = locks_to_send.next; 968 + lock_flocks(); 969 + cifs_for_each_lock(cfile->dentry->d_inode, before) { 970 + if (el == &locks_to_send) { 971 + /* something is really wrong */ 972 + cERROR(1, "Can't push all brlocks!"); 973 + break; 974 + } 957 975 flock = *before; 976 + if ((flock->fl_flags & FL_POSIX) == 0) 977 + continue; 958 978 length = 1 + flock->fl_end - flock->fl_start; 959 979 if (flock->fl_type == F_RDLCK || flock->fl_type == F_SHLCK) 960 980 type = CIFS_RDLCK; 961 981 else 962 982 type = CIFS_WRLCK; 963 - 964 - lck = cifs_lock_init(flock->fl_start, length, type, 965 - cfile->netfid); 966 - if (!lck) { 967 - rc = -ENOMEM; 968 - goto send_locks; 969 - } 983 + lck = list_entry(el, struct lock_to_push, llist); 970 984 lck->pid = flock->fl_pid; 971 - 972 - list_add_tail(&lck->llist, &locks_to_send); 985 + lck->netfid = cfile->netfid; 986 + lck->length = length; 987 + lck->type = type; 988 + lck->offset = flock->fl_start; 989 + i++; 990 + el = el->next; 973 991 } 974 - 975 - send_locks: 976 992 unlock_flocks(); 977 993 978 994 list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { ··· 1015 979 kfree(lck); 1016 980 } 1017 981 982 + out: 1018 983 cinode->can_cache_brlcks = false; 1019 984 mutex_unlock(&cinode->lock_mutex); 1020 985 1021 986 FreeXid(xid); 1022 987 return rc; 988 + err_out: 989 + list_for_each_entry_safe(lck, tmp, &locks_to_send, llist) { 990 + list_del(&lck->llist); 991 + kfree(lck); 992 + } 993 + goto out; 1023 994 } 1024 995 1025 996 static int
+3 -3
fs/cifs/xattr.c
··· 105 105 struct cifs_tcon *pTcon; 106 106 struct super_block *sb; 107 107 char *full_path; 108 - struct cifs_ntsd *pacl; 109 108 110 109 if (direntry == NULL) 111 110 return -EIO; ··· 163 164 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 164 165 } else if (strncmp(ea_name, CIFS_XATTR_CIFS_ACL, 165 166 strlen(CIFS_XATTR_CIFS_ACL)) == 0) { 167 + #ifdef CONFIG_CIFS_ACL 168 + struct cifs_ntsd *pacl; 166 169 pacl = kmalloc(value_size, GFP_KERNEL); 167 170 if (!pacl) { 168 171 cFYI(1, "%s: Can't allocate memory for ACL", 169 172 __func__); 170 173 rc = -ENOMEM; 171 174 } else { 172 - #ifdef CONFIG_CIFS_ACL 173 175 memcpy(pacl, ea_value, value_size); 174 176 rc = set_cifs_acl(pacl, value_size, 175 177 direntry->d_inode, full_path, CIFS_ACL_DACL); 176 178 if (rc == 0) /* force revalidate of the inode */ 177 179 CIFS_I(direntry->d_inode)->time = 0; 178 180 kfree(pacl); 181 + } 179 182 #else 180 183 cFYI(1, "Set CIFS ACL not supported yet"); 181 184 #endif /* CONFIG_CIFS_ACL */ 182 - } 183 185 } else { 184 186 int temp; 185 187 temp = strncmp(ea_name, POSIX_ACL_XATTR_ACCESS,