Re: [PATCH] rpmb: fix error path in rpmb_dev_register()

kernel test robot
2024-09-02T08:51:51Z

Hi Jens,

kernel test robot noticed the following build warnings:

[auto build test WARNING on next-20240829]
[cannot apply to v6.11-rc5 v6.11-rc4 v6.11-rc3 linus/master v6.11-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jens-Wiklander/rpmb-fix-error-path-in-rpmb_dev_register/20240830-141540
base: next-20240829
patch link: https://lore.kernel.org/r/20240830061404.2831708-1-jens.wiklander%40linaro.org
patch subject: [PATCH] rpmb: fix error path in rpmb_dev_register()
config: i386-randconfig-003-20240902 (https://download.01.org/0day-ci/archive/20240902/202409021647.u41JgxbX-lkp@intel.com/config)
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/20240902/202409021647.u41JgxbX-lkp@intel.com/reproduce)

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/202409021647.u41JgxbX-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/misc/rpmb-core.c:199:1: warning: unused label 'err_id_remove' [-Wunused-label]
199 | err_id_remove:
| ^~~~~~~~~~~~~~
1 warning generated.

vim +/err_id_remove +199 drivers/misc/rpmb-core.c

1e9046e3a15460 Jens Wiklander 2024-08-14 146
1e9046e3a15460 Jens Wiklander 2024-08-14 147 /**
1e9046e3a15460 Jens Wiklander 2024-08-14 148 * rpmb_dev_register - register RPMB partition with the RPMB subsystem
1e9046e3a15460 Jens Wiklander 2024-08-14 149 * @dev: storage device of the rpmb device
1e9046e3a15460 Jens Wiklander 2024-08-14 150 * @descr: RPMB device description
1e9046e3a15460 Jens Wiklander 2024-08-14 151 *
1e9046e3a15460 Jens Wiklander 2024-08-14 152 * While registering the RPMB partition extract needed device information
1e9046e3a15460 Jens Wiklander 2024-08-14 153 * while needed resources are available.
1e9046e3a15460 Jens Wiklander 2024-08-14 154 *
1e9046e3a15460 Jens Wiklander 2024-08-14 155 * Returns: a pointer to a 'struct rpmb_dev' or an ERR_PTR on failure
1e9046e3a15460 Jens Wiklander 2024-08-14 156 */
1e9046e3a15460 Jens Wiklander 2024-08-14 157 struct rpmb_dev *rpmb_dev_register(struct device *dev,
1e9046e3a15460 Jens Wiklander 2024-08-14 158 struct rpmb_descr *descr)
1e9046e3a15460 Jens Wiklander 2024-08-14 159 {
1e9046e3a15460 Jens Wiklander 2024-08-14 160 struct rpmb_dev *rdev;
1e9046e3a15460 Jens Wiklander 2024-08-14 161 int ret;
1e9046e3a15460 Jens Wiklander 2024-08-14 162
1e9046e3a15460 Jens Wiklander 2024-08-14 163 if (!dev || !descr || !descr->route_frames || !descr->dev_id ||
1e9046e3a15460 Jens Wiklander 2024-08-14 164 !descr->dev_id_len)
1e9046e3a15460 Jens Wiklander 2024-08-14 165 return ERR_PTR(-EINVAL);
1e9046e3a15460 Jens Wiklander 2024-08-14 166
1e9046e3a15460 Jens Wiklander 2024-08-14 167 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
1e9046e3a15460 Jens Wiklander 2024-08-14 168 if (!rdev)
1e9046e3a15460 Jens Wiklander 2024-08-14 169 return ERR_PTR(-ENOMEM);
1e9046e3a15460 Jens Wiklander 2024-08-14 170 rdev->descr = *descr;
1e9046e3a15460 Jens Wiklander 2024-08-14 171 rdev->descr.dev_id = kmemdup(descr->dev_id, descr->dev_id_len,
1e9046e3a15460 Jens Wiklander 2024-08-14 172 GFP_KERNEL);
1e9046e3a15460 Jens Wiklander 2024-08-14 173 if (!rdev->descr.dev_id) {
1e9046e3a15460 Jens Wiklander 2024-08-14 174 ret = -ENOMEM;
1e9046e3a15460 Jens Wiklander 2024-08-14 175 goto err_free_rdev;
1e9046e3a15460 Jens Wiklander 2024-08-14 176 }
1e9046e3a15460 Jens Wiklander 2024-08-14 177
1e9046e3a15460 Jens Wiklander 2024-08-14 178 mutex_lock(&rpmb_mutex);
1e9046e3a15460 Jens Wiklander 2024-08-14 179 ret = ida_simple_get(&rpmb_ida, 0, 0, GFP_KERNEL);
1e9046e3a15460 Jens Wiklander 2024-08-14 180 mutex_unlock(&rpmb_mutex);
1e9046e3a15460 Jens Wiklander 2024-08-14 181 if (ret < 0)
1e9046e3a15460 Jens Wiklander 2024-08-14 182 goto err_free_dev_id;
1e9046e3a15460 Jens Wiklander 2024-08-14 183 rdev->id = ret;
1e9046e3a15460 Jens Wiklander 2024-08-14 184
1e9046e3a15460 Jens Wiklander 2024-08-14 185 dev_set_name(&rdev->dev, "rpmb%d", rdev->id);
1e9046e3a15460 Jens Wiklander 2024-08-14 186 rdev->dev.class = &rpmb_class;
1e9046e3a15460 Jens Wiklander 2024-08-14 187 rdev->dev.parent = dev;
1e9046e3a15460 Jens Wiklander 2024-08-14 188
1e9046e3a15460 Jens Wiklander 2024-08-14 189 ret = device_register(&rdev->dev);
d1c997b32ba265 Jens Wiklander 2024-08-30 190 if (ret) {
d1c997b32ba265 Jens Wiklander 2024-08-30 191 put_device(&rdev->dev);
d1c997b32ba265 Jens Wiklander 2024-08-30 192 return ERR_PTR(ret);
d1c997b32ba265 Jens Wiklander 2024-08-30 193 }
1e9046e3a15460 Jens Wiklander 2024-08-14 194
1e9046e3a15460 Jens Wiklander 2024-08-14 195 dev_dbg(&rdev->dev, "registered device\n");
1e9046e3a15460 Jens Wiklander 2024-08-14 196
1e9046e3a15460 Jens Wiklander 2024-08-14 197 return rdev;
1e9046e3a15460 Jens Wiklander 2024-08-14 198
1e9046e3a15460 Jens Wiklander 2024-08-14 @199 err_id_remove:
1e9046e3a15460 Jens Wiklander 2024-08-14 200 mutex_lock(&rpmb_mutex);
1e9046e3a15460 Jens Wiklander 2024-08-14 201 ida_simple_remove(&rpmb_ida, rdev->id);
1e9046e3a15460 Jens Wiklander 2024-08-14 202 mutex_unlock(&rpmb_mutex);
1e9046e3a15460 Jens Wiklander 2024-08-14 203 err_free_dev_id:
1e9046e3a15460 Jens Wiklander 2024-08-14 204 kfree(rdev->descr.dev_id);
1e9046e3a15460 Jens Wiklander 2024-08-14 205 err_free_rdev:
1e9046e3a15460 Jens Wiklander 2024-08-14 206 kfree(rdev);
1e9046e3a15460 Jens Wiklander 2024-08-14 207 return ERR_PTR(ret);
1e9046e3a15460 Jens Wiklander 2024-08-14 208 }
1e9046e3a15460 Jens Wiklander 2024-08-14 209 EXPORT_SYMBOL_GPL(rpmb_dev_register);
1e9046e3a15460 Jens Wiklander 2024-08-14 210

--
0-DAY CI Kernel Test Service