This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 10d9dbaec29868abe50bbf41e44e0cbe62ebc48c Author: guoshengyuan3 <[email protected]> AuthorDate: Thu Nov 26 10:08:53 2026 +0800 drivers/misc/rpmsgblk: do not copy the ioctl argument from a NULL pointer rpmsgblk_default_ioctl() copied arglen bytes from arg, and gave arg to the reply copy, whenever the command has an argument size, also when the caller passed arg 0. UBSan reports this as "null pointer passed as argument 2". Copy the argument and the reply only when arg is not 0. Signed-off-by: guoshengyuan3 <[email protected]> Signed-off-by: Bowen Wang <[email protected]> --- drivers/misc/rpmsgblk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/misc/rpmsgblk.c b/drivers/misc/rpmsgblk.c index ea4410770f9..7d6c788116c 100644 --- a/drivers/misc/rpmsgblk.c +++ b/drivers/misc/rpmsgblk.c @@ -708,13 +708,14 @@ static int rpmsgblk_default_ioctl(FAR struct inode *inode, int cmd, msg->arg = arg; msg->arglen = arglen; - if (arglen > 0) + if (arg != 0 && arglen > 0) { memcpy(msg->buf, (FAR void *)(uintptr_t)arg, arglen); } return rpmsgblk_send_recv(priv, RPMSGBLK_IOCTL, false, &msg->header, - msglen, arglen > 0 ? (FAR void *)arg : NULL); + msglen, arglen > 0 && arg != 0 ? + (FAR void *)arg : NULL); } /****************************************************************************
