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 2077f65fe749c0f0c687af234bf82739b28a3219 Author: dengwenqi <[email protected]> AuthorDate: Wed May 13 23:28:07 2026 +0800 drivers/serial/pty: add NULL check for pollp in teardown path In pty_poll() teardown path (setup == false), pollp is assigned from fds->priv, which may be NULL if the matching setup call never ran or fds was reset by the caller. Dereferencing pollp->src/pollp->sink right after would crash the kernel. Add an explicit NULL check and return -EINVAL when pollp is NULL, so the subsequent POLLIN/POLLOUT branches safely operate on a valid poll record. Signed-off-by: dengwenqi <[email protected]> --- drivers/serial/pty.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index 689ee1cd0d8..1fdb6107129 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -1124,6 +1124,11 @@ static int pty_poll(FAR struct file *filep, FAR struct pollfd_s *fds, else { pollp = (FAR struct pty_poll_s *)fds->priv; + if (pollp == NULL) + { + ret = -EINVAL; + goto errout; + } } /* POLLIN: Data may be read without blocking. */
