diff options
| author | Jacob Moroni <jmoroni@google.com> | 2026-07-02 17:06:46 +0000 |
|---|---|---|
| committer | Leon Romanovsky <leon@kernel.org> | 2026-07-12 04:30:38 -0400 |
| commit | a833ce42d05624f27ac9b32e939df9caa7b06af3 (patch) | |
| tree | 7a335e3a0c99862ed205df6f7348150eaa398031 /include/rdma | |
| parent | b21d9bf627dd4162dd485f5f8d7d0fbdd71a175e (diff) | |
| download | linux-next-a833ce42d05624f27ac9b32e939df9caa7b06af3.tar.gz linux-next-a833ce42d05624f27ac9b32e939df9caa7b06af3.zip | |
RDMA/core: Add ib_no_udata_io() helper
In many cases, a driver op accepts no input data and provides
no response. This helper can be used in those handlers to
adhere to the uAPI forward/backward compat rules by failing
early if invalid udata is provided (whether input or output).
Signed-off-by: Jacob Moroni <jmoroni@google.com>
Link: https://patch.msgid.link/20260702170652.4159201-2-jmoroni@google.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'include/rdma')
| -rw-r--r-- | include/rdma/uverbs_ioctl.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/rdma/uverbs_ioctl.h b/include/rdma/uverbs_ioctl.h index 24fd36213023..80f3ba6663d0 100644 --- a/include/rdma/uverbs_ioctl.h +++ b/include/rdma/uverbs_ioctl.h @@ -1151,4 +1151,24 @@ static inline int ib_respond_empty_udata(struct ib_udata *udata) return 0; } +/** + * ib_no_udata_io - Ensure no input data and zero fill the response buffer + * @udata: The system call's ib_udata struct + * + * Driver ops which do not accept any input data and do not provide any response + * data may call this at the beginning of their handler to fully adhere to the + * uAPI forward/backward compatibility rules. + * + * Return: Negative failure code if the op should be denied, 0 otherwise. + */ +static inline int ib_no_udata_io(struct ib_udata *udata) +{ + int ret = ib_is_udata_in_empty(udata); + + if (ret) + return ret; + + return ib_respond_empty_udata(udata); +} + #endif |
