isobusfs: srv: check strdup() result when adding a new handle

The path of a handle is also used to mark the handle slot as used. When
strdup() failed the handle was returned to the client but the slot was
still marked as free and got reused (and the file descriptor of the
first user got lost) with the next open request.

Return -ENOMEM when the path can not be allocated. The callers close the
file descriptor and the handle slot remains unused.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
This commit is contained in:
Oliver Hartkopp
2026-10-14 10:21:56 +00:00
parent 3a980d83e0
commit cd0ff30788
+3
View File
@@ -45,6 +45,9 @@ static int isobusfs_srv_add_file(struct isobusfs_srv_priv *priv,
}
priv->handles[j].path = strdup(path);
if (!priv->handles[j].path)
return -ENOMEM;
priv->handles[j].fd = fd;
priv->handles[j].dir = dir;