* [l1k:doe 12/12] lib/spdm/req-netlink.c:123 spdm_netlink_sig_event() warn: missing unwind goto?
@ 2025-10-23 5:18 kernel test robot
2025-10-23 10:06 ` Lukas Wunner
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2025-10-23 5:18 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Lukas Wunner <lukas@wunner.de>
tree: https://github.com/l1k/linux doe
head: 7505d39770b6e267ed934902a491e499ab4e6153
commit: 7505d39770b6e267ed934902a491e499ab4e6153 [12/12] spdm: Multicast received signatures via netlink
:::::: branch date: 10 days ago
:::::: commit date: 10 days ago
config: loongarch-randconfig-r072-20251019 (https://download.01.org/0day-ci/archive/20251023/202510231302.hW7zNvXa-lkp@intel.com/config)
compiler: loongarch64-linux-gcc (GCC) 15.1.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 <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202510231302.hW7zNvXa-lkp@intel.com/
smatch warnings:
lib/spdm/req-netlink.c:123 spdm_netlink_sig_event() warn: missing unwind goto?
vim +123 lib/spdm/req-netlink.c
7505d39770b6e26 Lukas Wunner 2024-04-11 12
7505d39770b6e26 Lukas Wunner 2024-04-11 13 int spdm_netlink_sig_event(struct spdm_state *spdm_state,
7505d39770b6e26 Lukas Wunner 2024-04-11 14 enum spdm_reqrsp_code rsp_code, u8 slot,
7505d39770b6e26 Lukas Wunner 2024-04-11 15 size_t req_nonce_off, size_t rsp_nonce_off,
7505d39770b6e26 Lukas Wunner 2024-04-11 16 const char *spdm_context)
7505d39770b6e26 Lukas Wunner 2024-04-11 17 {
7505d39770b6e26 Lukas Wunner 2024-04-11 18 unsigned int seq, msg_sz, nr_msgs, nr_pages, nr_frags;
7505d39770b6e26 Lukas Wunner 2024-04-11 19 char *devpath __free(kfree) = NULL;
7505d39770b6e26 Lukas Wunner 2024-04-11 20 struct sk_buff *msg;
7505d39770b6e26 Lukas Wunner 2024-04-11 21 struct nlattr *nla;
7505d39770b6e26 Lukas Wunner 2024-04-11 22 void *hdr, *ptr;
7505d39770b6e26 Lukas Wunner 2024-04-11 23 int rc, i;
7505d39770b6e26 Lukas Wunner 2024-04-11 24
7505d39770b6e26 Lukas Wunner 2024-04-11 25 if (!genl_has_listeners(&spdm_nl_family, &init_net, SPDM_NLGRP_SIG))
7505d39770b6e26 Lukas Wunner 2024-04-11 26 return 0;
7505d39770b6e26 Lukas Wunner 2024-04-11 27
7505d39770b6e26 Lukas Wunner 2024-04-11 28 devpath = kobject_get_path(&spdm_state->dev->kobj, GFP_KERNEL);
7505d39770b6e26 Lukas Wunner 2024-04-11 29 if (!devpath)
7505d39770b6e26 Lukas Wunner 2024-04-11 30 return -ENOMEM;
7505d39770b6e26 Lukas Wunner 2024-04-11 31
7505d39770b6e26 Lukas Wunner 2024-04-11 32 nr_pages = spdm_state->transcript_max / PAGE_SIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 33 nr_msgs = DIV_ROUND_UP(nr_pages, MAX_SKB_FRAGS);
7505d39770b6e26 Lukas Wunner 2024-04-11 34
7505d39770b6e26 Lukas Wunner 2024-04-11 35 /* Calculate exact size to avoid reallocation by netlink_trim() */
7505d39770b6e26 Lukas Wunner 2024-04-11 36 msg_sz = nlmsg_total_size(genlmsg_msg_size(
7505d39770b6e26 Lukas Wunner 2024-04-11 37 nla_total_size(strlen(devpath)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 38 nla_total_size(sizeof(u8)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 39 nla_total_size(sizeof(u8)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 40 nla_total_size(sizeof(u16)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 41 nla_total_size(sizeof(u32)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 42 nla_total_size(sizeof(u32)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 43 nla_total_size(sizeof(u32)) +
7505d39770b6e26 Lukas Wunner 2024-04-11 44 nla_total_size(SPDM_COMBINED_PREFIX_SZ) +
7505d39770b6e26 Lukas Wunner 2024-04-11 45 nla_total_size(0)));
7505d39770b6e26 Lukas Wunner 2024-04-11 46
7505d39770b6e26 Lukas Wunner 2024-04-11 47 msg = genlmsg_new(msg_sz, GFP_KERNEL);
7505d39770b6e26 Lukas Wunner 2024-04-11 48 if (!msg)
7505d39770b6e26 Lukas Wunner 2024-04-11 49 return -ENOMEM;
7505d39770b6e26 Lukas Wunner 2024-04-11 50
7505d39770b6e26 Lukas Wunner 2024-04-11 51 hdr = genlmsg_put(msg, 0, 0, &spdm_nl_family,
7505d39770b6e26 Lukas Wunner 2024-04-11 52 nr_msgs > 1 ? NLM_F_MULTI : 0, SPDM_CMD_SIG);
7505d39770b6e26 Lukas Wunner 2024-04-11 53 if (!hdr) {
7505d39770b6e26 Lukas Wunner 2024-04-11 54 rc = -EMSGSIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 55 goto err_free_msg;
7505d39770b6e26 Lukas Wunner 2024-04-11 56 }
7505d39770b6e26 Lukas Wunner 2024-04-11 57
7505d39770b6e26 Lukas Wunner 2024-04-11 58 if (nla_put_string(msg, SPDM_A_SIG_DEVICE, devpath) ||
7505d39770b6e26 Lukas Wunner 2024-04-11 59 nla_put_u8(msg, SPDM_A_SIG_RSP_CODE, rsp_code) ||
7505d39770b6e26 Lukas Wunner 2024-04-11 60 nla_put_u8(msg, SPDM_A_SIG_SLOT, slot) ||
7505d39770b6e26 Lukas Wunner 2024-04-11 61 nla_put_u16(msg, SPDM_A_SIG_HASH_ALGO,
7505d39770b6e26 Lukas Wunner 2024-04-11 62 spdm_state->base_hash_alg) ||
7505d39770b6e26 Lukas Wunner 2024-04-11 63 nla_put_u32(msg, SPDM_A_SIG_SIG_OFFSET,
7505d39770b6e26 Lukas Wunner 2024-04-11 64 spdm_state->transcript_end - spdm_state->transcript -
7505d39770b6e26 Lukas Wunner 2024-04-11 65 spdm_state->sig_len) ||
7505d39770b6e26 Lukas Wunner 2024-04-11 66 nla_put_u32(msg, SPDM_A_SIG_REQ_NONCE_OFFSET, req_nonce_off) ||
7505d39770b6e26 Lukas Wunner 2024-04-11 67 nla_put_u32(msg, SPDM_A_SIG_RSP_NONCE_OFFSET, rsp_nonce_off)) {
7505d39770b6e26 Lukas Wunner 2024-04-11 68 rc = -EMSGSIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 69 goto err_cancel_msg;
7505d39770b6e26 Lukas Wunner 2024-04-11 70 }
7505d39770b6e26 Lukas Wunner 2024-04-11 71
7505d39770b6e26 Lukas Wunner 2024-04-11 72 if (spdm_state->version >= 0x12) {
7505d39770b6e26 Lukas Wunner 2024-04-11 73 nla = nla_reserve(msg, SPDM_A_SIG_COMBINED_SPDM_PREFIX,
7505d39770b6e26 Lukas Wunner 2024-04-11 74 SPDM_COMBINED_PREFIX_SZ);
7505d39770b6e26 Lukas Wunner 2024-04-11 75 if (!nla) {
7505d39770b6e26 Lukas Wunner 2024-04-11 76 rc = -EMSGSIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 77 goto err_cancel_msg;
7505d39770b6e26 Lukas Wunner 2024-04-11 78 }
7505d39770b6e26 Lukas Wunner 2024-04-11 79
7505d39770b6e26 Lukas Wunner 2024-04-11 80 spdm_create_combined_prefix(spdm_state->version, spdm_context,
7505d39770b6e26 Lukas Wunner 2024-04-11 81 nla_data(nla));
7505d39770b6e26 Lukas Wunner 2024-04-11 82 }
7505d39770b6e26 Lukas Wunner 2024-04-11 83
7505d39770b6e26 Lukas Wunner 2024-04-11 84 ptr = spdm_state->transcript;
7505d39770b6e26 Lukas Wunner 2024-04-11 85
7505d39770b6e26 Lukas Wunner 2024-04-11 86 /* Loop over Netlink messages - break condition is in loop body */
7505d39770b6e26 Lukas Wunner 2024-04-11 87 for (seq = 1; ; seq++) {
7505d39770b6e26 Lukas Wunner 2024-04-11 88 nla = nla_reserve(msg, SPDM_A_SIG_TRANSCRIPT, 0);
7505d39770b6e26 Lukas Wunner 2024-04-11 89 if (!nla) {
7505d39770b6e26 Lukas Wunner 2024-04-11 90 rc = -EMSGSIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 91 goto err_cancel_msg;
7505d39770b6e26 Lukas Wunner 2024-04-11 92 }
7505d39770b6e26 Lukas Wunner 2024-04-11 93
7505d39770b6e26 Lukas Wunner 2024-04-11 94 nr_frags = min(nr_pages, MAX_SKB_FRAGS);
7505d39770b6e26 Lukas Wunner 2024-04-11 95 nla->nla_len = nr_frags * PAGE_SIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 96 nr_pages -= nr_frags;
7505d39770b6e26 Lukas Wunner 2024-04-11 97
7505d39770b6e26 Lukas Wunner 2024-04-11 98 /* Loop over fragments of this Netlink message */
7505d39770b6e26 Lukas Wunner 2024-04-11 99 for (i = 0; i < nr_frags; i++) {
7505d39770b6e26 Lukas Wunner 2024-04-11 100 struct page *page = vmalloc_to_page(ptr);
7505d39770b6e26 Lukas Wunner 2024-04-11 101 size_t remainder = spdm_state->transcript_end - ptr;
7505d39770b6e26 Lukas Wunner 2024-04-11 102 size_t sz = min(remainder, PAGE_SIZE);
7505d39770b6e26 Lukas Wunner 2024-04-11 103
7505d39770b6e26 Lukas Wunner 2024-04-11 104 get_page(page);
7505d39770b6e26 Lukas Wunner 2024-04-11 105 skb_add_rx_frag(msg, i, page, 0, sz, sz);
7505d39770b6e26 Lukas Wunner 2024-04-11 106 ptr += PAGE_SIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 107 }
7505d39770b6e26 Lukas Wunner 2024-04-11 108
7505d39770b6e26 Lukas Wunner 2024-04-11 109 genlmsg_end(msg, hdr);
7505d39770b6e26 Lukas Wunner 2024-04-11 110 rc = genlmsg_multicast(&spdm_nl_family, msg, 0,
7505d39770b6e26 Lukas Wunner 2024-04-11 111 SPDM_NLGRP_SIG, GFP_KERNEL);
7505d39770b6e26 Lukas Wunner 2024-04-11 112 if (rc)
7505d39770b6e26 Lukas Wunner 2024-04-11 113 return rc;
7505d39770b6e26 Lukas Wunner 2024-04-11 114
7505d39770b6e26 Lukas Wunner 2024-04-11 115 if (nr_pages == 0) /* End of loop - entire transcript sent */
7505d39770b6e26 Lukas Wunner 2024-04-11 116 break;
7505d39770b6e26 Lukas Wunner 2024-04-11 117
7505d39770b6e26 Lukas Wunner 2024-04-11 118 /* Start new message for remainder of transcript */
7505d39770b6e26 Lukas Wunner 2024-04-11 119 msg_sz = nlmsg_total_size(genlmsg_msg_size(nla_total_size(0)));
7505d39770b6e26 Lukas Wunner 2024-04-11 120
7505d39770b6e26 Lukas Wunner 2024-04-11 121 msg = genlmsg_new(msg_sz, GFP_KERNEL);
7505d39770b6e26 Lukas Wunner 2024-04-11 122 if (!msg)
7505d39770b6e26 Lukas Wunner 2024-04-11 @123 return -ENOMEM;
7505d39770b6e26 Lukas Wunner 2024-04-11 124
7505d39770b6e26 Lukas Wunner 2024-04-11 125 hdr = genlmsg_put(msg, 0, seq, &spdm_nl_family,
7505d39770b6e26 Lukas Wunner 2024-04-11 126 NLM_F_MULTI, SPDM_CMD_SIG);
7505d39770b6e26 Lukas Wunner 2024-04-11 127 if (!hdr) {
7505d39770b6e26 Lukas Wunner 2024-04-11 128 rc = -EMSGSIZE;
7505d39770b6e26 Lukas Wunner 2024-04-11 129 goto err_free_msg;
7505d39770b6e26 Lukas Wunner 2024-04-11 130 }
7505d39770b6e26 Lukas Wunner 2024-04-11 131 }
7505d39770b6e26 Lukas Wunner 2024-04-11 132
7505d39770b6e26 Lukas Wunner 2024-04-11 133 return 0;
7505d39770b6e26 Lukas Wunner 2024-04-11 134
7505d39770b6e26 Lukas Wunner 2024-04-11 135 err_cancel_msg:
7505d39770b6e26 Lukas Wunner 2024-04-11 136 nlmsg_cancel(msg, hdr);
7505d39770b6e26 Lukas Wunner 2024-04-11 137 err_free_msg:
7505d39770b6e26 Lukas Wunner 2024-04-11 138 nlmsg_free(msg);
7505d39770b6e26 Lukas Wunner 2024-04-11 139 return rc;
7505d39770b6e26 Lukas Wunner 2024-04-11 140 }
7505d39770b6e26 Lukas Wunner 2024-04-11 141
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [l1k:doe 12/12] lib/spdm/req-netlink.c:123 spdm_netlink_sig_event() warn: missing unwind goto?
2025-10-23 5:18 [l1k:doe 12/12] lib/spdm/req-netlink.c:123 spdm_netlink_sig_event() warn: missing unwind goto? kernel test robot
@ 2025-10-23 10:06 ` Lukas Wunner
0 siblings, 0 replies; 2+ messages in thread
From: Lukas Wunner @ 2025-10-23 10:06 UTC (permalink / raw)
To: kernel test robot; +Cc: oe-kbuild, Dan Carpenter
On Thu, Oct 23, 2025 at 01:18:37PM +0800, kernel test robot wrote:
> tree: https://github.com/l1k/linux doe
> head: 7505d39770b6e267ed934902a491e499ab4e6153
> commit: 7505d39770b6e267ed934902a491e499ab4e6153 [12/12] spdm: Multicast received signatures via netlink
[...]
> smatch warnings:
> lib/spdm/req-netlink.c:123 spdm_netlink_sig_event() warn: missing unwind goto?
False positive:
> 7505d39770b6e26 Lukas Wunner 2024-04-11 13 int spdm_netlink_sig_event(struct spdm_state *spdm_state,
[...]
> 7505d39770b6e26 Lukas Wunner 2024-04-11 47 msg = genlmsg_new(msg_sz, GFP_KERNEL);
> 7505d39770b6e26 Lukas Wunner 2024-04-11 48 if (!msg)
> 7505d39770b6e26 Lukas Wunner 2024-04-11 49 return -ENOMEM;
New netlink message is allocated and subsequently filled with attributes.
> 7505d39770b6e26 Lukas Wunner 2024-04-11 86 /* Loop over Netlink messages - break condition is in loop body */
> 7505d39770b6e26 Lukas Wunner 2024-04-11 87 for (seq = 1; ; seq++) {
The function precalculates how many netlink messages it's going to need
to transmit the SPDM transcript. The transcript is a blob transmitted
as fragments of the skb.
> 7505d39770b6e26 Lukas Wunner 2024-04-11 98 /* Loop over fragments of this Netlink message */
> 7505d39770b6e26 Lukas Wunner 2024-04-11 99 for (i = 0; i < nr_frags; i++) {
The fragments are attached to the skb until the (compile-time defined)
maximum number of fragments is reached.
> 7505d39770b6e26 Lukas Wunner 2024-04-11 109 genlmsg_end(msg, hdr);
> 7505d39770b6e26 Lukas Wunner 2024-04-11 110 rc = genlmsg_multicast(&spdm_nl_family, msg, 0,
The message is sent out and thus implicitly discarded.
> 7505d39770b6e26 Lukas Wunner 2024-04-11 115 if (nr_pages == 0) /* End of loop - entire transcript sent */
> 7505d39770b6e26 Lukas Wunner 2024-04-11 116 break;
> 7505d39770b6e26 Lukas Wunner 2024-04-11 117
> 7505d39770b6e26 Lukas Wunner 2024-04-11 118 /* Start new message for remainder of transcript */
> 7505d39770b6e26 Lukas Wunner 2024-04-11 119 msg_sz = nlmsg_total_size(genlmsg_msg_size(nla_total_size(0)));
> 7505d39770b6e26 Lukas Wunner 2024-04-11 120
> 7505d39770b6e26 Lukas Wunner 2024-04-11 121 msg = genlmsg_new(msg_sz, GFP_KERNEL);
> 7505d39770b6e26 Lukas Wunner 2024-04-11 122 if (!msg)
> 7505d39770b6e26 Lukas Wunner 2024-04-11 @123 return -ENOMEM;
If the whole SPDM transcript hasn't been sent yet (end of loop condition),
then a new netlink message is begun. If allocation of the message fails,
the function may "return" directly without goto.
Thanks,
Lukas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-23 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 5:18 [l1k:doe 12/12] lib/spdm/req-netlink.c:123 spdm_netlink_sig_event() warn: missing unwind goto? kernel test robot
2025-10-23 10:06 ` Lukas Wunner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.