serial: smh: Check return value of strndup

strndup can fail. Check for it.

Fixes: 4855b39be ("serial: smh: Implement puts for DM")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c
index 4328b3d..2561414 100644
--- a/drivers/serial/serial_semihosting.c
+++ b/drivers/serial/serial_semihosting.c
@@ -54,6 +54,9 @@
 		}
 
 		buf = strndup(s, len);
+		if (!buf)
+			return -ENOMEM;
+
 		smh_puts(buf);
 		free(buf);
 		return len;