From: Eric Sandeen Date: Mon, 5 May 2014 07:27:06 +0000 (+1000) Subject: xfs: bulletfproof xfs_qm_scall_trunc_qfiles() X-Git-Tag: v3.16-rc1~46^2~5^2~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f58522c5a47a1862c6b3fad97ea9285c5d68199d;p=thirdparty%2Fkernel%2Flinux.git xfs: bulletfproof xfs_qm_scall_trunc_qfiles() Coverity noticed that if we sent junk into xfs_qm_scall_trunc_qfiles(), we could get back an uninitialized error value. So sanitize the flags we will accept, and initialize error anyway for good measure. (This bug may have been introduced via c61a9e39). Should resolve Coverity CID 1163872. Signed-off-by: Eric Sandeen Reviewed-by: Christoph Hellwig Reviewed-by: Jie Liu Signed-off-by: Dave Chinner --- diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 3daf5ea1eb8d7..f35f13b4ea73f 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c @@ -278,9 +278,10 @@ xfs_qm_scall_trunc_qfiles( xfs_mount_t *mp, uint flags) { - int error; + int error = EINVAL; - if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0) { + if (!xfs_sb_version_hasquota(&mp->m_sb) || flags == 0 || + (flags & ~XFS_DQ_ALLTYPES)) { xfs_debug(mp, "%s: flags=%x m_qflags=%x", __func__, flags, mp->m_qflags); return XFS_ERROR(EINVAL);