[PATCH 12/19] lib: make_directory: return -ENOMEM on allocation failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mkdir calls strdup on the dir that's passed in, but doesn't account for
allocation failure. Have it return -ENOMEM in that case.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 lib/make_directory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/make_directory.c b/lib/make_directory.c
index 7db93ded8817..59ac87e6bfdf 100644
--- a/lib/make_directory.c
+++ b/lib/make_directory.c
@@ -19,6 +19,9 @@ STATIC int make_directory(const char *dir)
 	char c;
 	int ret = 0;
 
+	if (!s)
+		return -ENOMEM;
+
 	do {
 		c = 0;
 
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux