[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202110011223.CY0JeX0i-lkp@intel.com>
Date: Fri, 1 Oct 2021 12:30:32 +0800
From: kernel test robot <lkp@...el.com>
To: Liu Yi L <yi.l.liu@...el.com>
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: [luxis1999-dev-iommu:dev-iommu-5.14-rfcv1 7/20]
drivers/iommu/iommufd/iommufd.c:181:7: warning: variable 'ret' is used
uninitialized whenever 'if' condition is true
tree: https://github.com/luxis1999/dev-iommu dev-iommu-5.14-rfcv1
head: 8d2f14a235e67092365d15107cfc357e86d69629
commit: e2fbb8c54de073a2a173e15b62884c64e6c4a4b6 [7/20] iommu/iommufd: Add iommufd_[un]bind_device()
config: riscv-randconfig-r042-20211001 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 962e503cc8bc411f7523cc393acae8aae425b1c4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/luxis1999/dev-iommu/commit/e2fbb8c54de073a2a173e15b62884c64e6c4a4b6
git remote add luxis1999-dev-iommu https://github.com/luxis1999/dev-iommu
git fetch --no-tags luxis1999-dev-iommu dev-iommu-5.14-rfcv1
git checkout e2fbb8c54de073a2a173e15b62884c64e6c4a4b6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> drivers/iommu/iommufd/iommufd.c:181:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (idev->dev == dev || idev->dev_cookie == dev_cookie) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/iommu/iommufd/iommufd.c:221:17: note: uninitialized use occurs here
return ERR_PTR(ret);
^~~
drivers/iommu/iommufd/iommufd.c:181:3: note: remove the 'if' if its condition is always false
if (idev->dev == dev || idev->dev_cookie == dev_cookie) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/iommu/iommufd/iommufd.c:181:7: warning: variable 'ret' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
if (idev->dev == dev || idev->dev_cookie == dev_cookie) {
^~~~~~~~~~~~~~~~
drivers/iommu/iommufd/iommufd.c:221:17: note: uninitialized use occurs here
return ERR_PTR(ret);
^~~
drivers/iommu/iommufd/iommufd.c:181:7: note: remove the '||' if its condition is always false
if (idev->dev == dev || idev->dev_cookie == dev_cookie) {
^~~~~~~~~~~~~~~~~~~
drivers/iommu/iommufd/iommufd.c:171:9: note: initialize the variable 'ret' to silence this warning
int ret;
^
= 0
2 warnings generated.
vim +181 drivers/iommu/iommufd/iommufd.c
151
152 /**
153 * iommufd_bind_device - Bind a physical device marked by a device
154 * cookie to an iommu fd.
155 * @fd: [in] iommufd file descriptor.
156 * @dev: [in] Pointer to a physical device struct.
157 * @dev_cookie: [in] A cookie to mark the device in /dev/iommu uAPI.
158 *
159 * A successful bind establishes a security context for the device
160 * and returns struct iommufd_device pointer. Otherwise returns
161 * error pointer.
162 *
163 */
164 struct iommufd_device *iommufd_bind_device(int fd, struct device *dev,
165 u64 dev_cookie)
166 {
167 struct iommufd_ctx *ictx;
168 struct iommufd_device *idev;
169 unsigned long index;
170 unsigned int id;
171 int ret;
172
173 ictx = iommufd_ctx_fdget(fd);
174 if (!ictx)
175 return ERR_PTR(-EINVAL);
176
177 mutex_lock(&ictx->lock);
178
179 /* check duplicate registration */
180 xa_for_each(&ictx->device_xa, index, idev) {
> 181 if (idev->dev == dev || idev->dev_cookie == dev_cookie) {
182 idev = ERR_PTR(-EBUSY);
183 goto out_unlock;
184 }
185 }
186
187 idev = kzalloc(sizeof(*idev), GFP_KERNEL);
188 if (!idev) {
189 ret = -ENOMEM;
190 goto out_unlock;
191 }
192
193 /* Establish the security context */
194 ret = iommu_device_init_user_dma(dev, (unsigned long)ictx);
195 if (ret)
196 goto out_free;
197
198 ret = xa_alloc(&ictx->device_xa, &id, idev,
199 XA_LIMIT(IOMMUFD_DEVID_MIN, IOMMUFD_DEVID_MAX),
200 GFP_KERNEL);
201 if (ret) {
202 idev = ERR_PTR(ret);
203 goto out_user_dma;
204 }
205
206 idev->ictx = ictx;
207 idev->dev = dev;
208 idev->dev_cookie = dev_cookie;
209 idev->id = id;
210 mutex_unlock(&ictx->lock);
211
212 return idev;
213 out_user_dma:
214 iommu_device_exit_user_dma(idev->dev);
215 out_free:
216 kfree(idev);
217 out_unlock:
218 mutex_unlock(&ictx->lock);
219 iommufd_ctx_put(ictx);
220
221 return ERR_PTR(ret);
222 }
223 EXPORT_SYMBOL_GPL(iommufd_bind_device);
224
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (34976 bytes)
Powered by blists - more mailing lists