lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210630133359.59275-1-m.shams@samsung.com>
Date:   Wed, 30 Jun 2021 19:03:59 +0530
From:   Tamseel Shams <m.shams@...sung.com>
To:     krzysztof.kozlowski@...onical.com, gregkh@...uxfoundation.org,
        jirislaby@...nel.org
Cc:     linux-arm-kernel@...ts.infradead.org,
        linux-samsung-soc@...r.kernel.org, linux-serial@...r.kernel.org,
        linux-kernel@...r.kernel.org, alim.akhtar@...sung.com,
        Tamseel Shams <m.shams@...sung.com>
Subject: [PATCH v2] serial: samsung: Checks the return value of function

"uart_add_one_port" function call may fail and return
some error code, so adding a check for return value.
If it is returning some error code, then displaying the
result, unregistering the driver and then returning from
probe function with error code.

Signed-off-by: Tamseel Shams <m.shams@...sung.com>
---
Changes since v1:
1. Added support to unregister driver on failure of "uart_add_onr_port"
function call.
2. Commit message updated.

 drivers/tty/serial/samsung_tty.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 9fbc61151c2e..188e2d2da201 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -2253,7 +2253,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 	}
 
 	dev_dbg(&pdev->dev, "%s: adding port\n", __func__);
-	uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
+	ret = uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "Failed to add uart port, err %d\n", ret);
+		goto add_port_error;
+	}
 	platform_set_drvdata(pdev, &ourport->port);
 
 	/*
@@ -2272,6 +2276,11 @@ static int s3c24xx_serial_probe(struct platform_device *pdev)
 	probe_index++;
 
 	return 0;
+
+add_port_error:
+	ourport->port.mapbase = 0;
+	uart_unregister_driver(&s3c24xx_uart_drv);
+	return ret;
 }
 
 static int s3c24xx_serial_remove(struct platform_device *dev)
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ