提交 7f8b4ebe 编写于 作者: S Souptick Joarder 提交者: Greg Kroah-Hartman

serial: ioc4_serial: Free memory when kzalloc fails during probe

Inside ioc4_attach_local() 4 memory was allocated using kzalloc and
assign it to ports[] within loop. When kzalloc fails inside loop,
it returns error without freeing previously allocated memory and we
may have memory leak. Fix this by freeing ports[] before return.
Signed-off-by: NSouptick joarder <jrdr.linux@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 65dabaf5
...@@ -1082,7 +1082,7 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd) ...@@ -1082,7 +1082,7 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
if (!port) { if (!port) {
printk(KERN_WARNING printk(KERN_WARNING
"IOC4 serial memory not available for port\n"); "IOC4 serial memory not available for port\n");
return -ENOMEM; goto free;
} }
spin_lock_init(&port->ip_lock); spin_lock_init(&port->ip_lock);
...@@ -1190,6 +1190,11 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd) ...@@ -1190,6 +1190,11 @@ static int inline ioc4_attach_local(struct ioc4_driver_data *idd)
handle_dma_error_intr, port); handle_dma_error_intr, port);
} }
return 0; return 0;
free:
while (port_number)
kfree(ports[--port_number]);
return -ENOMEM;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册