[PATCH 3/3] serial: sprd: cleanup the sprd_port when return -EPROBE_DEFER

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>

cleanup the sprd_port for the device when its .probe() would be called
later, and then alloc memory for its sprd_port again.

Signed-off-by: Chunyan Zhang <chunyan.zhang@xxxxxxxxxx>
---
 drivers/tty/serial/sprd_serial.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 914862844790..9917d7240172 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -1230,8 +1230,13 @@ static int sprd_probe(struct platform_device *pdev)
 	up->has_sysrq = IS_ENABLED(CONFIG_SERIAL_SPRD_CONSOLE);
 
 	ret = sprd_clk_init(up);
-	if (ret)
+	if (ret) {
+		if (ret == -EPROBE_DEFER) {
+			devm_kfree(&pdev->dev, sprd_port[index]);
+			sprd_port[index] = NULL;
+		}
 		return ret;
+	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	up->membase = devm_ioremap_resource(&pdev->dev, res);
-- 
2.20.1




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux