Re: [PATCH v3] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag

From: kernel test robot
Date: Thu Jun 22 2023 - 18:01:00 EST


Hi Sumitra,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf-next/master]
[also build test WARNING on bpf/master linus/master v6.4-rc7 next-20230622]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Sumitra-Sharma/lib-test_bpf-Call-page_address-on-page-acquired-with-GFP_KERNEL-flag/20230622-160846
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20230622080729.GA426913%40sumitra.com
patch subject: [PATCH v3] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20230623/202306230559.hU5Aonpl-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20230623/202306230559.hU5Aonpl-lkp@xxxxxxxxx/reproduce)

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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306230559.hU5Aonpl-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

lib/test_bpf.c: In function 'generate_test_data':
>> lib/test_bpf.c:14395:1: warning: label 'err_free_page' defined but not used [-Wunused-label]
14395 | err_free_page:
| ^~~~~~~~~~~~~


vim +/err_free_page +14395 lib/test_bpf.c

64a8946b447e41 Alexei Starovoitov 2014-05-08 14358
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14359 static void *generate_test_data(struct bpf_test *test, int sub)
64a8946b447e41 Alexei Starovoitov 2014-05-08 14360 {
bac142acb90e95 Nicolas Schichan 2015-08-04 14361 struct sk_buff *skb;
bac142acb90e95 Nicolas Schichan 2015-08-04 14362 struct page *page;
bac142acb90e95 Nicolas Schichan 2015-08-04 14363
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14364 if (test->aux & FLAG_NO_DATA)
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14365 return NULL;
64a8946b447e41 Alexei Starovoitov 2014-05-08 14366
f516420f683d14 Xu Kuohai 2022-03-21 14367 if (test->aux & FLAG_LARGE_MEM)
f516420f683d14 Xu Kuohai 2022-03-21 14368 return kmalloc(test->test[sub].data_size, GFP_KERNEL);
f516420f683d14 Xu Kuohai 2022-03-21 14369
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14370 /* Test case expects an skb, so populate one. Various
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14371 * subtests generate skbs of different sizes based on
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14372 * the same data.
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14373 */
bac142acb90e95 Nicolas Schichan 2015-08-04 14374 skb = populate_skb(test->data, test->test[sub].data_size);
bac142acb90e95 Nicolas Schichan 2015-08-04 14375 if (!skb)
bac142acb90e95 Nicolas Schichan 2015-08-04 14376 return NULL;
bac142acb90e95 Nicolas Schichan 2015-08-04 14377
bac142acb90e95 Nicolas Schichan 2015-08-04 14378 if (test->aux & FLAG_SKB_FRAG) {
bac142acb90e95 Nicolas Schichan 2015-08-04 14379 /*
bac142acb90e95 Nicolas Schichan 2015-08-04 14380 * when the test requires a fragmented skb, add a
bac142acb90e95 Nicolas Schichan 2015-08-04 14381 * single fragment to the skb, filled with
bac142acb90e95 Nicolas Schichan 2015-08-04 14382 * test->frag_data.
bac142acb90e95 Nicolas Schichan 2015-08-04 14383 */
bac142acb90e95 Nicolas Schichan 2015-08-04 14384 page = alloc_page(GFP_KERNEL);
bac142acb90e95 Nicolas Schichan 2015-08-04 14385
bac142acb90e95 Nicolas Schichan 2015-08-04 14386 if (!page)
bac142acb90e95 Nicolas Schichan 2015-08-04 14387 goto err_kfree_skb;
bac142acb90e95 Nicolas Schichan 2015-08-04 14388
4a8b1daa0ee566 Sumitra Sharma 2023-06-22 14389 memcpy(page_address(page), test->frag_data, MAX_DATA);
bac142acb90e95 Nicolas Schichan 2015-08-04 14390 skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA);
bac142acb90e95 Nicolas Schichan 2015-08-04 14391 }
bac142acb90e95 Nicolas Schichan 2015-08-04 14392
bac142acb90e95 Nicolas Schichan 2015-08-04 14393 return skb;
bac142acb90e95 Nicolas Schichan 2015-08-04 14394
bac142acb90e95 Nicolas Schichan 2015-08-04 @14395 err_free_page:
bac142acb90e95 Nicolas Schichan 2015-08-04 14396 __free_page(page);
bac142acb90e95 Nicolas Schichan 2015-08-04 14397 err_kfree_skb:
bac142acb90e95 Nicolas Schichan 2015-08-04 14398 kfree_skb(skb);
bac142acb90e95 Nicolas Schichan 2015-08-04 14399 return NULL;
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14400 }
10f18e0ba1ea7e Daniel Borkmann 2014-05-23 14401

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki