From 034fc93db7dfb35cb2eef11e6110dddc91e37e81 Mon Sep 17 00:00:00 2001 From: Ryan Erickson Date: Thu, 15 Feb 2024 13:57:05 -0600 Subject: [PATCH] modem: hl7800: Fix null reference in hl7800_net_addr6_pton Ensure a potential null pointer is not incremented. Signed-off-by: Ryan Erickson --- drivers/modem/hl7800.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/modem/hl7800.c b/drivers/modem/hl7800.c index a6e1444c7ce..a08e02104d8 100644 --- a/drivers/modem/hl7800.c +++ b/drivers/modem/hl7800.c @@ -1998,8 +1998,11 @@ static int hl7800_net_addr6_pton(const char *src, struct in6_addr *dst) ipv6_section = (uint16_t)strtol(src, NULL, 10); src = strchr(src, '.'); + if (!src) { + return -EINVAL; + } src++; - if (!src || *src == '\0') { + if (*src == '\0') { return -EINVAL; } ipv6_section = (ipv6_section << 8) | (uint16_t)strtol(src, NULL, 10);