Re: [PATCHv12 11/12] nvme: register fdp parameters with the block layer

Dan Carpenter
2024-12-10T08:45:48Z

Hi Keith,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Keith-Busch/fs-add-write-stream-information-to-statx/20241207-063826
base: https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link: https://lore.kernel.org/r/20241206221801.790690-12-kbusch%40meta.com
patch subject: [PATCHv12 11/12] nvme: register fdp parameters with the block layer
config: csky-randconfig-r072-20241209 (https://download.01.org/0day-ci/archive/20241210/202412100319.Y5vv98P8-lkp@intel.com/config)
compiler: csky-linux-gcc (GCC) 14.2.0

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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202412100319.Y5vv98P8-lkp@intel.com/

New smatch warnings:
drivers/nvme/host/core.c:2187 nvme_check_fdp() error: uninitialized symbol 'i'.
drivers/nvme/host/core.c:2232 nvme_query_fdp_info() warn: missing error code 'ret'

vim +/i +2187 drivers/nvme/host/core.c

04ca0849938146 Keith Busch 2024-12-06 2154 static int nvme_check_fdp(struct nvme_ns *ns, struct nvme_ns_info *info,
04ca0849938146 Keith Busch 2024-12-06 2155 u8 fdp_idx)
04ca0849938146 Keith Busch 2024-12-06 2156 {
04ca0849938146 Keith Busch 2024-12-06 2157 struct nvme_fdp_config_log hdr, *h;
04ca0849938146 Keith Busch 2024-12-06 2158 struct nvme_fdp_config_desc *desc;
04ca0849938146 Keith Busch 2024-12-06 2159 size_t size = sizeof(hdr);
04ca0849938146 Keith Busch 2024-12-06 2160 int i, n, ret;
04ca0849938146 Keith Busch 2024-12-06 2161 void *log;
04ca0849938146 Keith Busch 2024-12-06 2162
04ca0849938146 Keith Busch 2024-12-06 2163 info->runs = 0;
04ca0849938146 Keith Busch 2024-12-06 2164 ret = nvme_get_log_lsi(ns->ctrl, 0, NVME_LOG_FDP_CONFIGS, 0, NVME_CSI_NVM,
04ca0849938146 Keith Busch 2024-12-06 2165 (void *)&hdr, size, 0, info->endgid);
04ca0849938146 Keith Busch 2024-12-06 2166 if (ret)
04ca0849938146 Keith Busch 2024-12-06 2167 return ret;
04ca0849938146 Keith Busch 2024-12-06 2168
04ca0849938146 Keith Busch 2024-12-06 2169 size = le32_to_cpu(hdr.sze);
04ca0849938146 Keith Busch 2024-12-06 2170 h = kzalloc(size, GFP_KERNEL);
04ca0849938146 Keith Busch 2024-12-06 2171 if (!h)
04ca0849938146 Keith Busch 2024-12-06 2172 return 0;
04ca0849938146 Keith Busch 2024-12-06 2173
04ca0849938146 Keith Busch 2024-12-06 2174 ret = nvme_get_log_lsi(ns->ctrl, 0, NVME_LOG_FDP_CONFIGS, 0, NVME_CSI_NVM,
04ca0849938146 Keith Busch 2024-12-06 2175 h, size, 0, info->endgid);
04ca0849938146 Keith Busch 2024-12-06 2176 if (ret)
04ca0849938146 Keith Busch 2024-12-06 2177 goto out;
04ca0849938146 Keith Busch 2024-12-06 2178
04ca0849938146 Keith Busch 2024-12-06 2179 n = le16_to_cpu(h->numfdpc) + 1;
04ca0849938146 Keith Busch 2024-12-06 2180 if (fdp_idx > n)
04ca0849938146 Keith Busch 2024-12-06 2181 goto out;
04ca0849938146 Keith Busch 2024-12-06 2182
04ca0849938146 Keith Busch 2024-12-06 2183 log = h + 1;
04ca0849938146 Keith Busch 2024-12-06 2184 do {
04ca0849938146 Keith Busch 2024-12-06 2185 desc = log;
04ca0849938146 Keith Busch 2024-12-06 2186 log += le16_to_cpu(desc->dsze);
04ca0849938146 Keith Busch 2024-12-06 @2187 } while (i++ < fdp_idx);
^
i needs to be initialized to zero at the start.

04ca0849938146 Keith Busch 2024-12-06 2188
04ca0849938146 Keith Busch 2024-12-06 2189 info->runs = le64_to_cpu(desc->runs);
04ca0849938146 Keith Busch 2024-12-06 2190 out:
04ca0849938146 Keith Busch 2024-12-06 2191 kfree(h);
04ca0849938146 Keith Busch 2024-12-06 2192 return ret;
04ca0849938146 Keith Busch 2024-12-06 2193 }
04ca0849938146 Keith Busch 2024-12-06 2194
04ca0849938146 Keith Busch 2024-12-06 2195 static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
04ca0849938146 Keith Busch 2024-12-06 2196 {
04ca0849938146 Keith Busch 2024-12-06 2197 struct nvme_ns_head *head = ns->head;
04ca0849938146 Keith Busch 2024-12-06 2198 struct nvme_fdp_ruh_status *ruhs;
04ca0849938146 Keith Busch 2024-12-06 2199 struct nvme_fdp_config fdp;
04ca0849938146 Keith Busch 2024-12-06 2200 struct nvme_command c = {};
04ca0849938146 Keith Busch 2024-12-06 2201 int size, ret;
04ca0849938146 Keith Busch 2024-12-06 2202
04ca0849938146 Keith Busch 2024-12-06 2203 ret = nvme_get_features(ns->ctrl, NVME_FEAT_FDP, info->endgid, NULL, 0,
04ca0849938146 Keith Busch 2024-12-06 2204 &fdp);
04ca0849938146 Keith Busch 2024-12-06 2205 if (ret)
04ca0849938146 Keith Busch 2024-12-06 2206 goto err;
04ca0849938146 Keith Busch 2024-12-06 2207
04ca0849938146 Keith Busch 2024-12-06 2208 if (!(fdp.flags & FDPCFG_FDPE))
04ca0849938146 Keith Busch 2024-12-06 2209 goto err;
04ca0849938146 Keith Busch 2024-12-06 2210
04ca0849938146 Keith Busch 2024-12-06 2211 ret = nvme_check_fdp(ns, info, fdp.fdpcidx);
04ca0849938146 Keith Busch 2024-12-06 2212 if (ret || !info->runs)
04ca0849938146 Keith Busch 2024-12-06 2213 goto err;
04ca0849938146 Keith Busch 2024-12-06 2214
04ca0849938146 Keith Busch 2024-12-06 2215 size = struct_size(ruhs, ruhsd, NVME_MAX_PLIDS);
04ca0849938146 Keith Busch 2024-12-06 2216 ruhs = kzalloc(size, GFP_KERNEL);
04ca0849938146 Keith Busch 2024-12-06 2217 if (!ruhs) {
04ca0849938146 Keith Busch 2024-12-06 2218 ret = -ENOMEM;
04ca0849938146 Keith Busch 2024-12-06 2219 goto err;
04ca0849938146 Keith Busch 2024-12-06 2220 }
04ca0849938146 Keith Busch 2024-12-06 2221
04ca0849938146 Keith Busch 2024-12-06 2222 c.imr.opcode = nvme_cmd_io_mgmt_recv;
04ca0849938146 Keith Busch 2024-12-06 2223 c.imr.nsid = cpu_to_le32(head->ns_id);
04ca0849938146 Keith Busch 2024-12-06 2224 c.imr.mo = NVME_IO_MGMT_RECV_MO_RUHS;
04ca0849938146 Keith Busch 2024-12-06 2225 c.imr.numd = cpu_to_le32(nvme_bytes_to_numd(size));
04ca0849938146 Keith Busch 2024-12-06 2226 ret = nvme_submit_sync_cmd(ns->queue, &c, ruhs, size);
04ca0849938146 Keith Busch 2024-12-06 2227 if (ret)
04ca0849938146 Keith Busch 2024-12-06 2228 goto free;
04ca0849938146 Keith Busch 2024-12-06 2229
04ca0849938146 Keith Busch 2024-12-06 2230 head->nr_plids = le16_to_cpu(ruhs->nruhsd);
04ca0849938146 Keith Busch 2024-12-06 2231 if (!head->nr_plids)
04ca0849938146 Keith Busch 2024-12-06 @2232 goto free;

ret = -EINVAL?

04ca0849938146 Keith Busch 2024-12-06 2233
04ca0849938146 Keith Busch 2024-12-06 2234 kfree(ruhs);
04ca0849938146 Keith Busch 2024-12-06 2235 return 0;
04ca0849938146 Keith Busch 2024-12-06 2236
04ca0849938146 Keith Busch 2024-12-06 2237 free:
04ca0849938146 Keith Busch 2024-12-06 2238 kfree(ruhs);
04ca0849938146 Keith Busch 2024-12-06 2239 err:
04ca0849938146 Keith Busch 2024-12-06 2240 head->nr_plids = 0;
04ca0849938146 Keith Busch 2024-12-06 2241 info->runs = 0;
04ca0849938146 Keith Busch 2024-12-06 2242 return ret;
04ca0849938146 Keith Busch 2024-12-06 2243 }

--
0-DAY CI Kernel Test Service