[Concept,01/34] vfs: Fix NULL check after strdup() in dir_add_probe()

Message ID 20260403140523.1998228-2-sjg@u-boot.org
State New
Headers
Series Add a virtual filesystem (VFS) layer to U-Boot |

Commit Message

Simon Glass April 3, 2026, 2:04 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

The NULL check after strdup(path) tests the wrong variable (str
instead of dup_path), so a failed allocation is not caught.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 fs/dir-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/fs/dir-uclass.c b/fs/dir-uclass.c
index c5d7ef45d3b..0b55713cbdc 100644
--- a/fs/dir-uclass.c
+++ b/fs/dir-uclass.c
@@ -27,7 +27,7 @@  int dir_add_probe(struct udevice *fsdev, struct driver *drv, const char *path,
 	if (!str)
 		goto no_dev_name;
 	dup_path = strdup(path);
-	if (!str)
+	if (!dup_path)
 		goto no_dev_path;
 
 	ret = device_bind_with_driver_data(fsdev, drv, str, 0 /* data */,