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

cifs: properly handle case where CIFSGetSrvInodeNumber fails

...if it does then we pass a pointer to an unintialized variable for
the inode number to cifs_new_inode. Have it pass a NULL pointer instead.

Also tweak the function prototypes to reduce the amount of casting.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>

authored by

Jeff Layton and committed by
Steve French
950ec528 132ac7b7

+14 -15
+1 -2
fs/cifs/cifsproto.h
··· 92 92 extern __le64 cnvrtDosCifsTm(__u16 date, __u16 time); 93 93 extern struct timespec cnvrtDosUnixTm(__u16 date, __u16 time); 94 94 95 - extern struct inode *cifs_new_inode(struct super_block *sb, 96 - unsigned long *inum); 95 + extern struct inode *cifs_new_inode(struct super_block *sb, __u64 *inum); 97 96 extern int cifs_get_inode_info(struct inode **pinode, 98 97 const unsigned char *search_path, 99 98 FILE_ALL_INFO *pfile_info,
+10 -10
fs/cifs/inode.c
··· 213 213 * guaranteed to be unique. 214 214 */ 215 215 struct inode * 216 - cifs_new_inode(struct super_block *sb, unsigned long *inum) 216 + cifs_new_inode(struct super_block *sb, __u64 *inum) 217 217 { 218 218 struct inode *inode; 219 219 ··· 228 228 * if serverino is disabled, perhaps we should be using iunique()? 229 229 */ 230 230 if (inum && (CIFS_SB(sb)->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) 231 - inode->i_ino = *inum; 231 + inode->i_ino = (unsigned long) *inum; 232 232 233 233 /* 234 234 * must set this here instead of cifs_alloc_inode since VFS will ··· 276 276 277 277 /* get new inode */ 278 278 if (*pinode == NULL) { 279 - *pinode = cifs_new_inode(sb, (unsigned long *) 280 - &find_data.UniqueId); 279 + *pinode = cifs_new_inode(sb, &find_data.UniqueId); 281 280 if (*pinode == NULL) { 282 281 rc = -ENOMEM; 283 282 goto cgiiu_exit; ··· 498 499 /* get new inode */ 499 500 if (*pinode == NULL) { 500 501 __u64 inode_num; 502 + __u64 *pinum = &inode_num; 501 503 502 504 /* Is an i_ino of zero legal? Can we use that to check 503 505 if the server supports returning inode numbers? Are ··· 518 518 int rc1 = 0; 519 519 520 520 rc1 = CIFSGetSrvInodeNumber(xid, pTcon, 521 - full_path, &inode_num, 521 + full_path, pinum, 522 522 cifs_sb->local_nls, 523 523 cifs_sb->mnt_cifs_flags & 524 524 CIFS_MOUNT_MAP_SPECIAL_CHR); 525 525 if (rc1) { 526 526 cFYI(1, ("GetSrvInodeNum rc %d", rc1)); 527 + pinum = NULL; 527 528 /* BB EOPNOSUPP disable SERVER_INUM? */ 528 529 } 529 - *pinode = cifs_new_inode(sb, (unsigned long *) 530 - &inode_num); 531 530 } else { 532 - *pinode = cifs_new_inode(sb, NULL); 531 + pinum = NULL; 533 532 } 534 533 534 + *pinode = cifs_new_inode(sb, pinum); 535 535 if (*pinode == NULL) { 536 536 rc = -ENOMEM; 537 537 goto cgii_exit; ··· 1148 1148 else 1149 1149 direntry->d_op = &cifs_dentry_ops; 1150 1150 1151 - newinode = cifs_new_inode(inode->i_sb, (unsigned long *) 1152 - &pInfo->UniqueId); 1151 + newinode = cifs_new_inode(inode->i_sb, 1152 + &pInfo->UniqueId); 1153 1153 if (newinode == NULL) { 1154 1154 kfree(pInfo); 1155 1155 goto mkdir_get_info;
+3 -3
fs/cifs/readdir.c
··· 61 61 static int 62 62 construct_dentry(struct qstr *qstring, struct file *file, 63 63 struct inode **ptmp_inode, struct dentry **pnew_dentry, 64 - unsigned long *inum) 64 + __u64 *inum) 65 65 { 66 66 struct dentry *tmp_dentry = NULL; 67 67 struct super_block *sb = file->f_path.dentry->d_sb; ··· 820 820 /* inode num, inode type and filename returned */ 821 821 static int cifs_get_name_from_search_buf(struct qstr *pqst, 822 822 char *current_entry, __u16 level, unsigned int unicode, 823 - struct cifs_sb_info *cifs_sb, int max_len, ino_t *pinum) 823 + struct cifs_sb_info *cifs_sb, int max_len, __u64 *pinum) 824 824 { 825 825 int rc = 0; 826 826 unsigned int len = 0; ··· 903 903 struct qstr qstring; 904 904 struct cifsFileInfo *pCifsF; 905 905 unsigned int obj_type; 906 - ino_t inum; 906 + __u64 inum; 907 907 struct cifs_sb_info *cifs_sb; 908 908 struct inode *tmp_inode; 909 909 struct dentry *tmp_dentry;