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

[PATCH] reiserfs: add checking of journal_begin() return value

Check return values of journal_begin() and journal_end() in the quota code
for reiserfs.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Jan Kara and committed by
Linus Torvalds
bd6a1f16 92198f7e

+52 -20
+4 -2
fs/reiserfs/inode.c
··· 2798 2798 struct reiserfs_transaction_handle th; 2799 2799 2800 2800 /* (user+group)*(old+new) structure - we count quota info and , inode write (sb, inode) */ 2801 - journal_begin(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2); 2801 + error = journal_begin(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2); 2802 + if (error) 2803 + goto out; 2802 2804 error = DQUOT_TRANSFER(inode, attr) ? -EDQUOT : 0; 2803 2805 if (error) { 2804 2806 journal_end(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2); ··· 2813 2811 if (attr->ia_valid & ATTR_GID) 2814 2812 inode->i_gid = attr->ia_gid; 2815 2813 mark_inode_dirty(inode); 2816 - journal_end(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2); 2814 + error = journal_end(&th, inode->i_sb, 4*REISERFS_QUOTA_INIT_BLOCKS+2); 2817 2815 } 2818 2816 } 2819 2817 if (!error)
+48 -18
fs/reiserfs/super.c
··· 1841 1841 static int reiserfs_dquot_initialize(struct inode *inode, int type) 1842 1842 { 1843 1843 struct reiserfs_transaction_handle th; 1844 - int ret; 1844 + int ret, err; 1845 1845 1846 1846 /* We may create quota structure so we need to reserve enough blocks */ 1847 1847 reiserfs_write_lock(inode->i_sb); 1848 - journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1848 + ret = journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1849 + if (ret) 1850 + goto out; 1849 1851 ret = dquot_initialize(inode, type); 1850 - journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1852 + err = journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1853 + if (!ret && err) 1854 + ret = err; 1855 + out: 1851 1856 reiserfs_write_unlock(inode->i_sb); 1852 1857 return ret; 1853 1858 } ··· 1860 1855 static int reiserfs_dquot_drop(struct inode *inode) 1861 1856 { 1862 1857 struct reiserfs_transaction_handle th; 1863 - int ret; 1858 + int ret, err; 1864 1859 1865 1860 /* We may delete quota structure so we need to reserve enough blocks */ 1866 1861 reiserfs_write_lock(inode->i_sb); 1867 - journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1862 + ret = journal_begin(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1863 + if (ret) 1864 + goto out; 1868 1865 ret = dquot_drop(inode); 1869 - journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1866 + err = journal_end(&th, inode->i_sb, 2*REISERFS_QUOTA_INIT_BLOCKS); 1867 + if (!ret && err) 1868 + ret = err; 1869 + out: 1870 1870 reiserfs_write_unlock(inode->i_sb); 1871 1871 return ret; 1872 1872 } ··· 1879 1869 static int reiserfs_write_dquot(struct dquot *dquot) 1880 1870 { 1881 1871 struct reiserfs_transaction_handle th; 1882 - int ret; 1872 + int ret, err; 1883 1873 1884 1874 reiserfs_write_lock(dquot->dq_sb); 1885 - journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS); 1875 + ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS); 1876 + if (ret) 1877 + goto out; 1886 1878 ret = dquot_commit(dquot); 1887 - journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS); 1879 + err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_TRANS_BLOCKS); 1880 + if (!ret && err) 1881 + ret = err; 1882 + out: 1888 1883 reiserfs_write_unlock(dquot->dq_sb); 1889 1884 return ret; 1890 1885 } ··· 1897 1882 static int reiserfs_acquire_dquot(struct dquot *dquot) 1898 1883 { 1899 1884 struct reiserfs_transaction_handle th; 1900 - int ret; 1885 + int ret, err; 1901 1886 1902 1887 reiserfs_write_lock(dquot->dq_sb); 1903 - journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1888 + ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1889 + if (ret) 1890 + goto out; 1904 1891 ret = dquot_acquire(dquot); 1905 - journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1892 + err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1893 + if (!ret && err) 1894 + ret = err; 1895 + out: 1906 1896 reiserfs_write_unlock(dquot->dq_sb); 1907 1897 return ret; 1908 1898 } ··· 1915 1895 static int reiserfs_release_dquot(struct dquot *dquot) 1916 1896 { 1917 1897 struct reiserfs_transaction_handle th; 1918 - int ret; 1898 + int ret, err; 1919 1899 1920 1900 reiserfs_write_lock(dquot->dq_sb); 1921 - journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1901 + ret = journal_begin(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1902 + if (ret) 1903 + goto out; 1922 1904 ret = dquot_release(dquot); 1923 - journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1905 + err = journal_end(&th, dquot->dq_sb, REISERFS_QUOTA_INIT_BLOCKS); 1906 + if (!ret && err) 1907 + ret = err; 1908 + out: 1924 1909 reiserfs_write_unlock(dquot->dq_sb); 1925 1910 return ret; 1926 1911 } ··· 1945 1920 static int reiserfs_write_info(struct super_block *sb, int type) 1946 1921 { 1947 1922 struct reiserfs_transaction_handle th; 1948 - int ret; 1923 + int ret, err; 1949 1924 1950 1925 /* Data block + inode block */ 1951 1926 reiserfs_write_lock(sb); 1952 - journal_begin(&th, sb, 2); 1927 + ret = journal_begin(&th, sb, 2); 1928 + if (ret) 1929 + goto out; 1953 1930 ret = dquot_commit_info(sb, type); 1954 - journal_end(&th, sb, 2); 1931 + err = journal_end(&th, sb, 2); 1932 + if (!ret && err) 1933 + ret = err; 1934 + out: 1955 1935 reiserfs_write_unlock(sb); 1956 1936 return ret; 1957 1937 }