Re: [PATCH v5 2/3] remoteproc: Add inline coredump functionality

From: kernel test robot
Date: Thu Jun 25 2020 - 14:34:41 EST


Hi Rishabh,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.8-rc2 next-20200625]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Rishabh-Bhatnagar/Extend-coredump-functionality/20200624-092759
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 5e857ce6eae7ca21b2055cca4885545e29228fe2
config: h8300-randconfig-m031-20200624 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

smatch warnings:
drivers/remoteproc/remoteproc_coredump.c:186 rproc_coredump_read() warn: unsigned 'copy_sz' is never less than zero.

vim +/copy_sz +186 drivers/remoteproc/remoteproc_coredump.c

171
172 static ssize_t rproc_coredump_read(char *buffer, loff_t offset, size_t count,
173 void *data, size_t header_sz)
174 {
175 size_t seg_data;
176 size_t copy_sz, bytes_left = count;
177 struct rproc_dump_segment *seg;
178 struct rproc_coredump_state *dump_state = data;
179 struct rproc *rproc = dump_state->rproc;
180 void *elfcore = dump_state->header;
181
182 /* Copy the vmalloc'ed header first. */
183 if (offset < header_sz) {
184 copy_sz = memory_read_from_buffer(buffer, count, &offset,
185 elfcore, header_sz);
> 186 if (copy_sz < 0)
187 return -EINVAL;
188
189 return copy_sz;
190 }
191
192 /*
193 * Find out the segment memory chunk to be copied based on offset.
194 * Keep copying data until count bytes are read.
195 */
196 while (bytes_left) {
197 seg = rproc_coredump_find_segment(offset - header_sz,
198 &rproc->dump_segments,
199 &seg_data);
200 /* EOF check */
201 if (!seg) {
202 dev_info(&rproc->dev, "Ramdump done, %lld bytes read",
203 offset);
204 break;
205 }
206
207 copy_sz = min_t(size_t, bytes_left, seg_data);
208
209 rproc_copy_segment(rproc, buffer, seg, seg->size - seg_data,
210 copy_sz);
211
212 offset += copy_sz;
213 buffer += copy_sz;
214 bytes_left -= copy_sz;
215 }
216
217 return count - bytes_left;
218 }
219

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip