[bootlin/training-materials updates] master: linux: serial: Check return value from of_property_read_u32() (349d97c5)
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Fri Oct 29 10:46:37 CEST 2021
Repository : https://github.com/bootlin/training-materials
On branch : master
Link : https://github.com/bootlin/training-materials/commit/349d97c51ad999e64578b42d89fa4a5176f3bde1
>---------------------------------------------------------------
commit 349d97c51ad999e64578b42d89fa4a5176f3bde1
Author: Miquel Raynal <miquel.raynal at bootlin.com>
Date: Wed May 5 23:07:51 2021 +0200
linux: serial: Check return value from of_property_read_u32()
The return value should be checked otherwise we might end up working with a
wrong uartclk value.
Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
>---------------------------------------------------------------
349d97c51ad999e64578b42d89fa4a5176f3bde1
labs/kernel-serial-iomem/uart-line-init.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/labs/kernel-serial-iomem/uart-line-init.c b/labs/kernel-serial-iomem/uart-line-init.c
index 9b181e51..9c629a8b 100644
--- a/labs/kernel-serial-iomem/uart-line-init.c
+++ b/labs/kernel-serial-iomem/uart-line-init.c
@@ -1,7 +1,13 @@
/* Configure the baud rate to 115200 */
-of_property_read_u32(pdev->dev.of_node, "clock-frequency",
- &uartclk);
+ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
+ &uartclk);
+if (ret) {
+ dev_err(&pdev->dev,
+ "clock-frequency property not found in Device Tree\n");
+ return ret;
+}
+
baud_divisor = uartclk / 16 / 115200;
reg_write(serial, 0x07, UART_OMAP_MDR1);
reg_write(serial, 0x00, UART_LCR);
More information about the training-materials-updates
mailing list