[linux-nvme:nvme-5.9-rc 14/14] drivers/nvme/host/zns.c:170:46: warning: Uninitialized variable: buflen
kernel test robot
lkp at intel.com
Thu Aug 27 18:51:54 EDT 2020
tree: git://git.infradead.org/nvme.git nvme-5.9-rc
head: cd83b396e350d2f13bd2ad81565255f77a13aa3a
commit: cd83b396e350d2f13bd2ad81565255f77a13aa3a [14/14] nvme: fix error handling in nvme_ns_report_zones
compiler: sparc64-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
cppcheck warnings: (new ones prefixed by >>)
>> drivers/nvme/host/zns.c:170:46: warning: Uninitialized variable: buflen [uninitvar]
c.zmr.numd = cpu_to_le32(nvme_bytes_to_numd(buflen));
^
>> drivers/nvme/host/nvme.h:523:10: warning: Uninitialized variable: len [uninitvar]
return (len >> 2) - 1;
^
git remote add linux-nvme git://git.infradead.org/nvme.git
git fetch --no-tags linux-nvme nvme-5.9-rc
git checkout cd83b396e350d2f13bd2ad81565255f77a13aa3a
vim +170 drivers/nvme/host/zns.c
158
159 static int nvme_ns_report_zones(struct nvme_ns *ns, sector_t sector,
160 unsigned int nr_zones, report_zones_cb cb, void *data)
161 {
162 struct nvme_zone_report *report;
163 struct nvme_command c = { };
164 int ret, zone_idx = 0;
165 unsigned int nz, i;
166 size_t buflen;
167
168 c.zmr.opcode = nvme_cmd_zone_mgmt_recv;
169 c.zmr.nsid = cpu_to_le32(ns->head->ns_id);
> 170 c.zmr.numd = cpu_to_le32(nvme_bytes_to_numd(buflen));
171 c.zmr.zra = NVME_ZRA_ZONE_REPORT;
172 c.zmr.zrasf = NVME_ZRASF_ZONE_REPORT_ALL;
173 c.zmr.pr = NVME_REPORT_ZONE_PARTIAL;
174
175 report = nvme_zns_alloc_report_buffer(ns, nr_zones, &buflen);
176 if (!report)
177 return -ENOMEM;
178
179 sector &= ~(ns->zsze - 1);
180 while (zone_idx < nr_zones && sector < get_capacity(ns->disk)) {
181 memset(report, 0, buflen);
182
183 c.zmr.slba = cpu_to_le64(nvme_sect_to_lba(ns, sector));
184 ret = nvme_submit_sync_cmd(ns->queue, &c, report, buflen);
185 if (ret)
186 goto out_free;
187
188 nz = min((unsigned int)le64_to_cpu(report->nr_zones), nr_zones);
189 if (!nz)
190 break;
191
192 for (i = 0; i < nz && zone_idx < nr_zones; i++) {
193 ret = nvme_zone_parse_entry(ns, &report->entries[i],
194 zone_idx, cb, data);
195 if (ret)
196 goto out_free;
197 zone_idx++;
198 }
199
200 sector += ns->zsze * nz;
201 }
202
203 if (zone_idx > 0)
204 ret = zone_idx;
205 else
206 ret = -EINVAL;
207 out_free:
208 kvfree(report);
209 return ret;
210 }
211
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
More information about the Linux-nvme
mailing list