* [PATCH] serial: smh: Check return value of strndup
@ 2022-04-22 18:50 Sean Anderson
2022-05-05 23:38 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Sean Anderson @ 2022-04-22 18:50 UTC (permalink / raw)
To: u-boot, Tom Rini; +Cc: Simon Glass, Sean Anderson
strndup can fail. Check for it.
Fixes: 4855b39be ("serial: smh: Implement puts for DM")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---
drivers/serial/serial_semihosting.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/serial/serial_semihosting.c b/drivers/serial/serial_semihosting.c
index 4328b3dac5..2561414e40 100644
--- a/drivers/serial/serial_semihosting.c
+++ b/drivers/serial/serial_semihosting.c
@@ -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;
--
2.35.1.1320.gc452695387.dirty
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] serial: smh: Check return value of strndup
2022-04-22 18:50 [PATCH] serial: smh: Check return value of strndup Sean Anderson
@ 2022-05-05 23:38 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2022-05-05 23:38 UTC (permalink / raw)
To: Sean Anderson; +Cc: u-boot, Simon Glass
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
On Fri, Apr 22, 2022 at 02:50:23PM -0400, Sean Anderson wrote:
> strndup can fail. Check for it.
>
> Fixes: 4855b39be ("serial: smh: Implement puts for DM")
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Applied to u-boot/master, thanks!
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-05 23:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 18:50 [PATCH] serial: smh: Check return value of strndup Sean Anderson
2022-05-05 23:38 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.