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>
This commit is contained in:
Sean Anderson 2022-04-22 14:50:23 -04:00 committed by Tom Rini
parent 30705cd892
commit bfae2744dd

View file

@ -54,6 +54,9 @@ static ssize_t smh_serial_puts(struct udevice *dev, const char *s, size_t len)
}
buf = strndup(s, len);
if (!buf)
return -ENOMEM;
smh_puts(buf);
free(buf);
return len;