[cifs:for-next 9/9] fs/cifs/smb2ops.c:1867:10: warning: 'rc' may be used uninitialized in this function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   git://git.samba.org/sfrench/cifs-2.6.git for-next
head:   92129244f4fd2b0b4c02c99001ccb8303df28fcb
commit: 92129244f4fd2b0b4c02c99001ccb8303df28fcb [9/9] cifs: fix smb3-encryption crashes with CONFIG_DEBUG_SG
config: i386-randconfig-x007-201807 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        git checkout 92129244f4fd2b0b4c02c99001ccb8303df28fcb
        # save the attached .config to linux build tree
        make ARCH=i386 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   fs/cifs/smb2ops.c: In function 'smb3_punch_hole':
   fs/cifs/smb2ops.c:1788:6: warning: statement with no effect [-Wunused-value]
      rc -ENOMEM;
   fs/cifs/smb2ops.c: In function 'smb3_fallocate':
>> fs/cifs/smb2ops.c:1867:10: warning: 'rc' may be used uninitialized in this function [-Wmaybe-uninitialized]
      return smb3_punch_hole(file, tcon, off, len);
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/rc +1867 fs/cifs/smb2ops.c

30175628b Steve French    2014-08-17  1760  
31742c5a3 Steve French    2014-08-17  1761  static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
31742c5a3 Steve French    2014-08-17  1762  			    loff_t offset, loff_t len)
31742c5a3 Steve French    2014-08-17  1763  {
31742c5a3 Steve French    2014-08-17  1764  	struct inode *inode;
31742c5a3 Steve French    2014-08-17  1765  	struct cifsInodeInfo *cifsi;
31742c5a3 Steve French    2014-08-17  1766  	struct cifsFileInfo *cfile = file->private_data;
92129244f Ronnie Sahlberg 2018-02-19  1767  	struct file_zero_data_information *fsctl_buf;
31742c5a3 Steve French    2014-08-17  1768  	long rc;
31742c5a3 Steve French    2014-08-17  1769  	unsigned int xid;
31742c5a3 Steve French    2014-08-17  1770  
31742c5a3 Steve French    2014-08-17  1771  	xid = get_xid();
31742c5a3 Steve French    2014-08-17  1772  
2b0143b5c David Howells   2015-03-17  1773  	inode = d_inode(cfile->dentry);
31742c5a3 Steve French    2014-08-17  1774  	cifsi = CIFS_I(inode);
31742c5a3 Steve French    2014-08-17  1775  
31742c5a3 Steve French    2014-08-17  1776  	/* Need to make file sparse, if not already, before freeing range. */
31742c5a3 Steve French    2014-08-17  1777  	/* Consider adding equivalent for compressed since it could also work */
92129244f Ronnie Sahlberg 2018-02-19  1778  	if (!smb2_set_sparse(xid, tcon, cfile, inode, 1)) {
92129244f Ronnie Sahlberg 2018-02-19  1779  		rc = -EOPNOTSUPP;
92129244f Ronnie Sahlberg 2018-02-19  1780  		goto out;
92129244f Ronnie Sahlberg 2018-02-19  1781  	}
31742c5a3 Steve French    2014-08-17  1782  	cifs_dbg(FYI, "offset %lld len %lld", offset, len);
31742c5a3 Steve French    2014-08-17  1783  
92129244f Ronnie Sahlberg 2018-02-19  1784  	fsctl_buf = kzalloc(sizeof(struct file_zero_data_information),
92129244f Ronnie Sahlberg 2018-02-19  1785  			    GFP_KERNEL);
92129244f Ronnie Sahlberg 2018-02-19  1786  	if (!fsctl_buf) {
92129244f Ronnie Sahlberg 2018-02-19  1787  		cifs_dbg(VFS, "failed to allocate fsctl_buf\n");
92129244f Ronnie Sahlberg 2018-02-19 @1788  		rc -ENOMEM;
92129244f Ronnie Sahlberg 2018-02-19  1789  		goto out;
92129244f Ronnie Sahlberg 2018-02-19  1790  	}
92129244f Ronnie Sahlberg 2018-02-19  1791  	fsctl_buf->FileOffset = cpu_to_le64(offset);
92129244f Ronnie Sahlberg 2018-02-19  1792  	fsctl_buf->BeyondFinalZero = cpu_to_le64(offset + len);
31742c5a3 Steve French    2014-08-17  1793  
31742c5a3 Steve French    2014-08-17  1794  	rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid,
31742c5a3 Steve French    2014-08-17  1795  			cfile->fid.volatile_fid, FSCTL_SET_ZERO_DATA,
92129244f Ronnie Sahlberg 2018-02-19  1796  			true /* is_fctl */, (char *)fsctl_buf,
31742c5a3 Steve French    2014-08-17  1797  			sizeof(struct file_zero_data_information), NULL, NULL);
92129244f Ronnie Sahlberg 2018-02-19  1798  	kfree(fsctl_buf);
92129244f Ronnie Sahlberg 2018-02-19  1799  out:
31742c5a3 Steve French    2014-08-17  1800  	free_xid(xid);
31742c5a3 Steve French    2014-08-17  1801  	return rc;
31742c5a3 Steve French    2014-08-17  1802  }
31742c5a3 Steve French    2014-08-17  1803  
9ccf32162 Steve French    2014-10-18  1804  static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon,
9ccf32162 Steve French    2014-10-18  1805  			    loff_t off, loff_t len, bool keep_size)
9ccf32162 Steve French    2014-10-18  1806  {
9ccf32162 Steve French    2014-10-18  1807  	struct inode *inode;
9ccf32162 Steve French    2014-10-18  1808  	struct cifsInodeInfo *cifsi;
9ccf32162 Steve French    2014-10-18  1809  	struct cifsFileInfo *cfile = file->private_data;
9ccf32162 Steve French    2014-10-18  1810  	long rc = -EOPNOTSUPP;
9ccf32162 Steve French    2014-10-18  1811  	unsigned int xid;
9ccf32162 Steve French    2014-10-18  1812  
9ccf32162 Steve French    2014-10-18  1813  	xid = get_xid();
9ccf32162 Steve French    2014-10-18  1814  
2b0143b5c David Howells   2015-03-17  1815  	inode = d_inode(cfile->dentry);
9ccf32162 Steve French    2014-10-18  1816  	cifsi = CIFS_I(inode);
9ccf32162 Steve French    2014-10-18  1817  
9ccf32162 Steve French    2014-10-18  1818  	/* if file not oplocked can't be sure whether asking to extend size */
9ccf32162 Steve French    2014-10-18  1819  	if (!CIFS_CACHE_READ(cifsi))
9ccf32162 Steve French    2014-10-18  1820  		if (keep_size == false)
9ccf32162 Steve French    2014-10-18  1821  			return -EOPNOTSUPP;
9ccf32162 Steve French    2014-10-18  1822  
9ccf32162 Steve French    2014-10-18  1823  	/*
9ccf32162 Steve French    2014-10-18  1824  	 * Files are non-sparse by default so falloc may be a no-op
9ccf32162 Steve French    2014-10-18  1825  	 * Must check if file sparse. If not sparse, and not extending
9ccf32162 Steve French    2014-10-18  1826  	 * then no need to do anything since file already allocated
9ccf32162 Steve French    2014-10-18  1827  	 */
9ccf32162 Steve French    2014-10-18  1828  	if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) {
9ccf32162 Steve French    2014-10-18  1829  		if (keep_size == true)
9ccf32162 Steve French    2014-10-18  1830  			return 0;
9ccf32162 Steve French    2014-10-18  1831  		/* check if extending file */
9ccf32162 Steve French    2014-10-18  1832  		else if (i_size_read(inode) >= off + len)
9ccf32162 Steve French    2014-10-18  1833  			/* not extending file and already not sparse */
9ccf32162 Steve French    2014-10-18  1834  			return 0;
9ccf32162 Steve French    2014-10-18  1835  		/* BB: in future add else clause to extend file */
9ccf32162 Steve French    2014-10-18  1836  		else
9ccf32162 Steve French    2014-10-18  1837  			return -EOPNOTSUPP;
9ccf32162 Steve French    2014-10-18  1838  	}
9ccf32162 Steve French    2014-10-18  1839  
9ccf32162 Steve French    2014-10-18  1840  	if ((keep_size == true) || (i_size_read(inode) >= off + len)) {
9ccf32162 Steve French    2014-10-18  1841  		/*
9ccf32162 Steve French    2014-10-18  1842  		 * Check if falloc starts within first few pages of file
9ccf32162 Steve French    2014-10-18  1843  		 * and ends within a few pages of the end of file to
9ccf32162 Steve French    2014-10-18  1844  		 * ensure that most of file is being forced to be
9ccf32162 Steve French    2014-10-18  1845  		 * fallocated now. If so then setting whole file sparse
9ccf32162 Steve French    2014-10-18  1846  		 * ie potentially making a few extra pages at the beginning
9ccf32162 Steve French    2014-10-18  1847  		 * or end of the file non-sparse via set_sparse is harmless.
9ccf32162 Steve French    2014-10-18  1848  		 */
9ccf32162 Steve French    2014-10-18  1849  		if ((off > 8192) || (off + len + 8192 < i_size_read(inode)))
9ccf32162 Steve French    2014-10-18  1850  			return -EOPNOTSUPP;
9ccf32162 Steve French    2014-10-18  1851  
92129244f Ronnie Sahlberg 2018-02-19  1852  		rc = smb2_set_sparse(xid, tcon, cfile, inode, 0);
9ccf32162 Steve French    2014-10-18  1853  	}
9ccf32162 Steve French    2014-10-18  1854  	/* BB: else ... in future add code to extend file and set sparse */
9ccf32162 Steve French    2014-10-18  1855  
9ccf32162 Steve French    2014-10-18  1856  
9ccf32162 Steve French    2014-10-18  1857  	free_xid(xid);
9ccf32162 Steve French    2014-10-18  1858  	return rc;
9ccf32162 Steve French    2014-10-18  1859  }
9ccf32162 Steve French    2014-10-18  1860  
9ccf32162 Steve French    2014-10-18  1861  
31742c5a3 Steve French    2014-08-17  1862  static long smb3_fallocate(struct file *file, struct cifs_tcon *tcon, int mode,
31742c5a3 Steve French    2014-08-17  1863  			   loff_t off, loff_t len)
31742c5a3 Steve French    2014-08-17  1864  {
31742c5a3 Steve French    2014-08-17  1865  	/* KEEP_SIZE already checked for by do_fallocate */
31742c5a3 Steve French    2014-08-17  1866  	if (mode & FALLOC_FL_PUNCH_HOLE)
31742c5a3 Steve French    2014-08-17 @1867  		return smb3_punch_hole(file, tcon, off, len);
30175628b Steve French    2014-08-17  1868  	else if (mode & FALLOC_FL_ZERO_RANGE) {
30175628b Steve French    2014-08-17  1869  		if (mode & FALLOC_FL_KEEP_SIZE)
30175628b Steve French    2014-08-17  1870  			return smb3_zero_range(file, tcon, off, len, true);
30175628b Steve French    2014-08-17  1871  		return smb3_zero_range(file, tcon, off, len, false);
9ccf32162 Steve French    2014-10-18  1872  	} else if (mode == FALLOC_FL_KEEP_SIZE)
9ccf32162 Steve French    2014-10-18  1873  		return smb3_simple_falloc(file, tcon, off, len, true);
9ccf32162 Steve French    2014-10-18  1874  	else if (mode == 0)
9ccf32162 Steve French    2014-10-18  1875  		return smb3_simple_falloc(file, tcon, off, len, false);
31742c5a3 Steve French    2014-08-17  1876  
31742c5a3 Steve French    2014-08-17  1877  	return -EOPNOTSUPP;
31742c5a3 Steve French    2014-08-17  1878  }
31742c5a3 Steve French    2014-08-17  1879  

:::::: The code at line 1867 was first introduced by commit
:::::: 31742c5a331766bc7df6b0d525df00c6cd20d5a6 enable fallocate punch hole ("fallocate -p") for SMB3

:::::: TO: Steve French <smfrench@xxxxxxxxx>
:::::: CC: Steve French <smfrench@xxxxxxxxx>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux