Commit 807eb70
committed
libibverbs: Skip zero-length memcpy in fill_attr_in()
fill_attr_in() unconditionally calls memcpy() when len <= sizeof(u64),
even if len is zero. In commit d9af497 ("verbs: Add ibv_cmd_alloc/free
commands for DMA handle"), the call
fill_attr_in_enum(cmdb, UVERBS_ATTR_ALLOC_DMAH_TPH_MEM_TYPE,
attr->tph_mem_type, NULL, 0);
started passing a NULL data pointer together with len == 0, which leads
to memcpy() being invoked with a NULL source address. While nothing is
actually copied, some compilers and sanitizers treat this as undefined
behavior and emit errors.
Avoid this by skipping memcpy() when len is zero. Zero-length attributes
have no payload, so this does not change behaviour.
fill_attr_in() was originally introduced in commit c344635 ("verbs: Add
basic infrastructure support for the kabi ioctl").
Fixes: d9af497 ("verbs: Add ibv_cmd_alloc/free commands for DMA handle")
Signed-off-by: Yijing Zeng <zengyijing19900106@gmail.com>1 parent 2241546 commit 807eb70
1 file changed
+5
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
285 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
286 | 287 | | |
| 288 | + | |
287 | 289 | | |
288 | 290 | | |
289 | 291 | | |
| |||
0 commit comments