[bootlin/training-materials updates] master: linux: serial: Check return value from of_property_read_u32() (98ca795f)

Miquel Raynal miquel.raynal at bootlin.com
Wed May 5 23:09:20 CEST 2021


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/98ca795fc5becd6fe1c681bfa14904f8afd53ca2

>---------------------------------------------------------------

commit 98ca795fc5becd6fe1c681bfa14904f8afd53ca2
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>


>---------------------------------------------------------------

98ca795fc5becd6fe1c681bfa14904f8afd53ca2
 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