tree:
https://android.googlesource.com/kernel/common android-trusty-5.4
head: 055ccbe92295978be3d8d20275b35b5e8779664d
commit: ad087eec5da18a8b73a9db488cc60fc48a10a026 [28/32] ANDROID: trusty: Add stdcalltest
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
cppcheck warnings: (new ones prefixed by >>)
> drivers/trusty/trusty-test.c:81:6: warning: Variable
'ret' is reassigned a value before the old one has been used.
[redundantAssignment]
ret = sg_alloc_table_from_pages(&obj->sgt,
obj->pages, page_count,
^
drivers/trusty/trusty-test.c:43:0: note: Variable 'ret' is reassigned a value
before the old one has been used.
int ret = -ENOMEM;
^
drivers/trusty/trusty-test.c:81:6: note: Variable 'ret' is reassigned a value
before the old one has been used.
ret = sg_alloc_table_from_pages(&obj->sgt, obj->pages, page_count,
^
drivers/trusty/trusty-test.c:311:10: warning: Uninitialized variable: obj [uninitvar]
ret, obj->mem_id, i, repeat_share);
^
vim +/ret +81 drivers/trusty/trusty-test.c
32
33 /*
34 * Allocate a test object with @page_count number of pages, map it and add it to
35 * @list.
36 * For multi-page allocations, order the pages so they are not contiguous.
37 */
38 static int trusty_test_alloc_obj(struct trusty_test_state *s,
39 size_t page_count,
40 struct list_head *list)
41 {
42 size_t i;
43 int ret = -ENOMEM;
44 struct trusty_test_shmem_obj *obj;
45
46 obj = kzalloc(sizeof(*obj), GFP_KERNEL);
47 if (!obj)
48 goto err_alloc_obj;
49 obj->page_count = page_count;
50
51 obj->pages = kmalloc_array(page_count, sizeof(*obj->pages), GFP_KERNEL);
52 if (!obj->pages) {
53 ret = -ENOMEM;
54 dev_err(s->dev, "failed to allocate page array, count %zd\n",
55 page_count);
56 goto err_alloc_pages;
57 }
58
59 for (i = 0; i < page_count; i++) {
60 obj->pages[i] = alloc_page(GFP_KERNEL);
61 if (!obj->pages[i]) {
62 ret = -ENOMEM;
63 dev_err(s->dev, "failed to allocate page %zd/%zd\n",
64 i, page_count);
65 goto err_alloc_page;
66 }
67 if (i > 0 && obj->pages[i - 1] + 1 == obj->pages[i]) {
68 /* swap adacent pages to increase fragmentation */
69 swap(obj->pages[i - 1], obj->pages[i]);
70 }
71 }
72
73 obj->buf = vmap(obj->pages, page_count, VM_MAP, PAGE_KERNEL);
74 if (!obj->buf) {
75 ret = -ENOMEM;
76 dev_err(s->dev, "failed to map test buffer page count %zd\n",
77 page_count);
78 goto err_map_pages;
79 }
80
81 ret = sg_alloc_table_from_pages(&obj->sgt, obj->pages,
page_count,
82 0, page_count * PAGE_SIZE, GFP_KERNEL);
83 if (ret) {
84 dev_err(s->dev, "sg_alloc_table_from_pages failed: %d\n", ret);
85 goto err_alloc_sgt;
86 }
87 list_add_tail(&obj->node, list);
88 dev_dbg(s->dev, "buffer has %d page runs\n", obj->sgt.nents);
89 return 0;
90
91 err_alloc_sgt:
92 vunmap(obj->buf);
93 err_map_pages:
94 for (i = page_count; i > 0; i--) {
95 __free_page(obj->pages[i - 1]);
96 err_alloc_page:
97 ;
98 }
99 kfree(obj->pages);
100 err_alloc_pages:
101 kfree(obj);
102 err_alloc_obj:
103 return ret;
104 }
105
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org