[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201109122919.GN18329@kadam>
Date: Mon, 9 Nov 2020 15:29:19 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...ts.01.org, SrujanaChalla <schalla@...vell.com>
Cc: lkp@...el.com, Dan Carpenter <error27@...il.com>,
kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
Herbert Xu <herbert@...dor.apana.org.au>
Subject: [kbuild] drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c:1300
create_engine_group() error: we previously assumed 'mirrored_eng_grp' could
be null (see line 1256)
Hi SrujanaChalla,
First bad commit (maybe != root cause):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f8394f232b1eab649ce2df5c5f15b0e528c92091
commit: 6482023b9d3350bf1b756ef36e1ea1a1c871879c crypto: marvell - enable OcteonTX cpt options for build
config: x86_64-randconfig-m001-20201109 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
New smatch warnings:
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c:1300 create_engine_group() error: we previously assumed 'mirrored_eng_grp' could be null (see line 1256)
vim +/mirrored_eng_grp +1300 drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1206 static int create_engine_group(struct device *dev,
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1207 struct otx_cpt_eng_grps *eng_grps,
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1208 struct otx_cpt_engines *engs, int engs_cnt,
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1209 void *ucode_data[], int ucodes_cnt,
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1210 bool use_uc_from_tar_arch)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1211 {
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1212 struct otx_cpt_eng_grp_info *mirrored_eng_grp;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1213 struct tar_ucode_info_t *tar_info;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1214 struct otx_cpt_eng_grp_info *eng_grp;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1215 int i, ret = 0;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1216
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1217 if (ucodes_cnt > OTX_CPT_MAX_ETYPES_PER_GRP)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1218 return -EINVAL;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1219
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1220 /* Validate if requested engine types are supported by this device */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1221 for (i = 0; i < engs_cnt; i++)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1222 if (!dev_supports_eng_type(eng_grps, engs[i].type)) {
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1223 dev_err(dev, "Device does not support %s engines",
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1224 get_eng_type_str(engs[i].type));
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1225 return -EPERM;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1226 }
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1227
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1228 /* Find engine group which is not used */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1229 eng_grp = find_unused_eng_grp(eng_grps);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1230 if (!eng_grp) {
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1231 dev_err(dev, "Error all engine groups are being used");
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1232 return -ENOSPC;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1233 }
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1234
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1235 /* Load ucode */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1236 for (i = 0; i < ucodes_cnt; i++) {
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1237 if (use_uc_from_tar_arch) {
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1238 tar_info = (struct tar_ucode_info_t *) ucode_data[i];
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1239 eng_grp->ucode[i] = tar_info->ucode;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1240 ret = copy_ucode_to_dma_mem(dev, &eng_grp->ucode[i],
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1241 tar_info->ucode_ptr);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1242 } else
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1243 ret = ucode_load(dev, &eng_grp->ucode[i],
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1244 (char *) ucode_data[i]);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1245 if (ret)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1246 goto err_ucode_unload;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1247 }
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1248
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1249 /* Validate scenario where 1 ucode is used */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1250 ret = validate_1_ucode_scenario(dev, eng_grp, engs, engs_cnt);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1251 if (ret)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1252 goto err_ucode_unload;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1253
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1254 /* Check if this group mirrors another existing engine group */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1255 mirrored_eng_grp = find_mirrored_eng_grp(eng_grp);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 @1256 if (mirrored_eng_grp) {
^^^^^^^^^^^^^^^^
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1257 /* Setup mirroring */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1258 setup_eng_grp_mirroring(eng_grp, mirrored_eng_grp);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1259
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1260 /*
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1261 * Update count of requested engines because some
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1262 * of them might be shared with mirrored group
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1263 */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1264 update_requested_engs(mirrored_eng_grp, engs, engs_cnt);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1265 }
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1266
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1267 /* Reserve engines */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1268 ret = reserve_engines(dev, eng_grp, engs, engs_cnt);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1269 if (ret)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1270 goto err_ucode_unload;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1271
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1272 /* Update ucode pointers used by engines */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1273 update_ucode_ptrs(eng_grp);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1274
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1275 /* Update engine masks used by this group */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1276 ret = eng_grp_update_masks(dev, eng_grp);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1277 if (ret)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1278 goto err_release_engs;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1279
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1280 /* Create sysfs entry for engine group info */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1281 ret = create_sysfs_eng_grps_info(dev, eng_grp);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1282 if (ret)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1283 goto err_release_engs;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1284
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1285 /* Enable engine group */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1286 ret = enable_eng_grp(eng_grp, eng_grps->obj);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1287 if (ret)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1288 goto err_release_engs;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1289
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1290 /*
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1291 * If this engine group mirrors another engine group
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1292 * then we need to unload ucode as we will use ucode
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1293 * from mirrored engine group
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1294 */
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1295 if (eng_grp->mirror.is_ena)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1296 ucode_unload(dev, &eng_grp->ucode[0]);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1297
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1298 eng_grp->is_enabled = true;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1299 if (eng_grp->mirror.is_ena)
d9110b0b01ff1cd SrujanaChalla 2020-03-13 @1300 dev_info(dev,
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1301 "Engine_group%d: reuse microcode %s from group %d",
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1302 eng_grp->idx, mirrored_eng_grp->ucode[0].ver_str,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1303 mirrored_eng_grp->idx);
^^^^^^^^^^^^^^^^^^^^^
Unchecked dereferences.
Possibly the "eng_grp->mirror.is_ena" means this is a false positive.
Too hard to tell without more context.
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1304 else
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1305 dev_info(dev, "Engine_group%d: microcode loaded %s",
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1306 eng_grp->idx, eng_grp->ucode[0].ver_str);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1307
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1308 return 0;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1309
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1310 err_release_engs:
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1311 release_engines(dev, eng_grp);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1312 err_ucode_unload:
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1313 ucode_unload(dev, &eng_grp->ucode[0]);
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1314 return ret;
d9110b0b01ff1cd SrujanaChalla 2020-03-13 1315 }
Download attachment ".config.gz" of type "application/gzip" (44877 bytes)
_______________________________________________
kbuild mailing list -- kbuild@...ts.01.org
To unsubscribe send an email to kbuild-leave@...ts.01.org
Powered by blists - more mailing lists