From: Johan Hovold Date: Fri, 17 Sep 2021 11:46:20 +0000 (+0200) Subject: ipack: ipoctal: fix missing allocation-failure check X-Git-Tag: Ubuntu-5.4.0-91.102~35 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=e9b6f16358446530d5ebc63638589609dd0389a2;p=mirror_ubuntu-focal-kernel.git ipack: ipoctal: fix missing allocation-failure check BugLink: https://bugs.launchpad.net/bugs/1947888 commit 445c8132727728dc297492a7d9fc074af3e94ba3 upstream. Add the missing error handling when allocating the transmit buffer to avoid dereferencing a NULL pointer in write() should the allocation ever fail. Fixes: ba4dc61fe8c5 ("Staging: ipack: add support for IP-OCTAL mezzanine board") Cc: stable@vger.kernel.org # 3.5 Acked-by: Samuel Iglesias Gonsalvez Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20210917114622.5412-5-johan@kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Kamal Mostafa Signed-off-by: Kelsey Skunberg --- diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index 498f52784c3a..e22696ebd406 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -388,7 +388,9 @@ static int ipoctal_inst_slot(struct ipoctal *ipoctal, unsigned int bus_nr, channel = &ipoctal->channel[i]; tty_port_init(&channel->tty_port); - tty_port_alloc_xmit_buf(&channel->tty_port); + res = tty_port_alloc_xmit_buf(&channel->tty_port); + if (res) + continue; channel->tty_port.ops = &ipoctal_tty_port_ops; ipoctal_reset_stats(&channel->stats);