tree: https://gitee.com/openeuler/kernel.git OLK-5.10 head: cbfb00d89c3b9971c3f0732b4f34d4e674bff5d8 commit: b6c35c29c4b795fa72f7acecb07e94502f159bec [26326/30000] quota: Fix potential NULL pointer dereference config: x86_64-randconfig-122-20240910 (https://download.01.org/0day-ci/archive/20240911/202409110955.mmx8Aa4b-lkp@i...) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240911/202409110955.mmx8Aa4b-lkp@i...)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot lkp@intel.com | Closes: https://lore.kernel.org/oe-kbuild-all/202409110955.mmx8Aa4b-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
fs/quota/dquot.c:1699:25: sparse: sparse: incompatible types in comparison expression (different address spaces):
fs/quota/dquot.c:1699:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1699:25: sparse: struct dquot * fs/quota/dquot.c:1710:41: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1710:41: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1710:41: sparse: struct dquot * fs/quota/dquot.c:1760:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1760:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1760:25: sparse: struct dquot * fs/quota/dquot.c:1766:41: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1766:41: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1766:41: sparse: struct dquot * fs/quota/dquot.c:1810:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1810:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1810:25: sparse: struct dquot * fs/quota/dquot.c:1852:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1852:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1852:25: sparse: struct dquot * fs/quota/dquot.c:1901:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1901:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1901:25: sparse: struct dquot * fs/quota/dquot.c:1949:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:1949:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:1949:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot * fs/quota/dquot.c:409:25: sparse: sparse: incompatible types in comparison expression (different address spaces): fs/quota/dquot.c:409:25: sparse: struct dquot [noderef] __rcu * fs/quota/dquot.c:409:25: sparse: struct dquot *
vim +1699 fs/quota/dquot.c
1659 1660 /* 1661 * This functions updates i_blocks+i_bytes fields and quota information 1662 * (together with appropriate checks). 1663 * 1664 * NOTE: We absolutely rely on the fact that caller dirties the inode 1665 * (usually helpers in quotaops.h care about this) and holds a handle for 1666 * the current transaction so that dquot write and inode write go into the 1667 * same transaction. 1668 */ 1669 1670 /* 1671 * This operation can block, but only after everything is updated 1672 */ 1673 int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) 1674 { 1675 int cnt, ret = 0, index; 1676 struct dquot_warn warn[MAXQUOTAS]; 1677 int reserve = flags & DQUOT_SPACE_RESERVE; 1678 struct dquot **dquots; 1679 struct dquot *dquot; 1680 1681 if (!inode_quota_active(inode)) { 1682 if (reserve) { 1683 spin_lock(&inode->i_lock); 1684 *inode_reserved_space(inode) += number; 1685 spin_unlock(&inode->i_lock); 1686 } else { 1687 inode_add_bytes(inode, number); 1688 } 1689 goto out; 1690 } 1691 1692 for (cnt = 0; cnt < MAXQUOTAS; cnt++) 1693 warn[cnt].w_type = QUOTA_NL_NOWARN; 1694 1695 dquots = i_dquot(inode); 1696 index = srcu_read_lock(&dquot_srcu); 1697 spin_lock(&inode->i_lock); 1698 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
1699 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1700 if (!dquot) 1701 continue; 1702 if (reserve) { 1703 ret = dquot_add_space(dquot, 0, number, flags, &warn[cnt]); 1704 } else { 1705 ret = dquot_add_space(dquot, number, 0, flags, &warn[cnt]); 1706 } 1707 if (ret) { 1708 /* Back out changes we already did */ 1709 for (cnt--; cnt >= 0; cnt--) { 1710 dquot = srcu_dereference(dquots[cnt], &dquot_srcu); 1711 if (!dquot) 1712 continue; 1713 spin_lock(&dquot->dq_dqb_lock); 1714 if (reserve) 1715 dquot_free_reserved_space(dquot, number); 1716 else 1717 dquot_decr_space(dquot, number); 1718 spin_unlock(&dquot->dq_dqb_lock); 1719 } 1720 spin_unlock(&inode->i_lock); 1721 goto out_flush_warn; 1722 } 1723 } 1724 if (reserve) 1725 *inode_reserved_space(inode) += number; 1726 else 1727 __inode_add_bytes(inode, number); 1728 spin_unlock(&inode->i_lock); 1729 1730 if (reserve) 1731 goto out_flush_warn; 1732 mark_all_dquot_dirty(dquots); 1733 out_flush_warn: 1734 srcu_read_unlock(&dquot_srcu, index); 1735 flush_warnings(warn); 1736 out: 1737 return ret; 1738 } 1739 EXPORT_SYMBOL(__dquot_alloc_space); 1740