Re: drivers/iommu/amd/iommu.c:2011 init_gcr3_table() warn: missing error code? 'ret'

From: Vasant Hegde
Date: Fri May 31 2024 - 04:32:57 EST


Hi Dan,


On 5/23/2024 8:39 PM, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 29c73fc794c83505066ee6db893b2a83ac5fac63
> commit: c9e8701132e6cc162d082e7dad8a2e9110f5f8fd iommu/amd: Setup GCR3 table in advance if domain is SVA capable
> config: x86_64-randconfig-161-20240522 (https://download.01.org/0day-ci/archive/20240522/202405221116.X7cP3GzG-lkp@xxxxxxxxx/config)
> compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
>
> 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@xxxxxxxxx>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202405221116.X7cP3GzG-lkp@xxxxxxxxx/
>
> smatch warnings:
> drivers/iommu/amd/iommu.c:2011 init_gcr3_table() warn: missing error code? 'ret'
>
> vim +/ret +2011 drivers/iommu/amd/iommu.c
>
> c9e8701132e6cc Vasant Hegde 2024-04-18 1986 static int init_gcr3_table(struct iommu_dev_data *dev_data,
> c9e8701132e6cc Vasant Hegde 2024-04-18 1987 struct protection_domain *pdom)
> c9e8701132e6cc Vasant Hegde 2024-04-18 1988 {
> c9e8701132e6cc Vasant Hegde 2024-04-18 1989 struct amd_iommu *iommu = get_amd_iommu_from_dev_data(dev_data);
> c9e8701132e6cc Vasant Hegde 2024-04-18 1990 int max_pasids = dev_data->max_pasids;
> c9e8701132e6cc Vasant Hegde 2024-04-18 1991 int ret = 0;
> c9e8701132e6cc Vasant Hegde 2024-04-18 1992
> c9e8701132e6cc Vasant Hegde 2024-04-18 1993 /*
> c9e8701132e6cc Vasant Hegde 2024-04-18 1994 * If domain is in pt mode then setup GCR3 table only if device
> c9e8701132e6cc Vasant Hegde 2024-04-18 1995 * is PASID capable
> c9e8701132e6cc Vasant Hegde 2024-04-18 1996 */
> c9e8701132e6cc Vasant Hegde 2024-04-18 1997 if (pdom_is_in_pt_mode(pdom) && !pdev_pasid_supported(dev_data))
> c9e8701132e6cc Vasant Hegde 2024-04-18 1998 return ret;
> c9e8701132e6cc Vasant Hegde 2024-04-18 1999
> c9e8701132e6cc Vasant Hegde 2024-04-18 2000 /*
> c9e8701132e6cc Vasant Hegde 2024-04-18 2001 * By default, setup GCR3 table to support MAX PASIDs
> c9e8701132e6cc Vasant Hegde 2024-04-18 2002 * supported by the device/IOMMU.
> c9e8701132e6cc Vasant Hegde 2024-04-18 2003 */
> c9e8701132e6cc Vasant Hegde 2024-04-18 2004 ret = setup_gcr3_table(&dev_data->gcr3_info, iommu,
> c9e8701132e6cc Vasant Hegde 2024-04-18 2005 max_pasids > 0 ? max_pasids : 1);
> c9e8701132e6cc Vasant Hegde 2024-04-18 2006 if (ret)
> c9e8701132e6cc Vasant Hegde 2024-04-18 2007 return ret;
> c9e8701132e6cc Vasant Hegde 2024-04-18 2008
> c9e8701132e6cc Vasant Hegde 2024-04-18 2009 /* Setup GCR3[0] only if domain is setup with v2 page table mode */
> c9e8701132e6cc Vasant Hegde 2024-04-18 2010 if (!pdom_is_v2_pgtbl_mode(pdom))
> c9e8701132e6cc Vasant Hegde 2024-04-18 @2011 return ret;
>
> From the comment, this looks like a false positive, but could you please
> change it to "return 0;"

ret is already zero. Hence I used 'ret'. Yeah . I can change this to zero.

-Vasant