Skip to contentSkip to conversation

of_serial: Fix possible null dereference.

PATCH Superseded John Linn 3 participants 3 messages Mar 20, 2008 – Mar 21, 2008

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

John Linn

author
#0 lore raw

PATCH 1/3 of_serial: Fix possible null dereference.

From: Stephen Neuendorffer <[email protected]>

The of_serial driver queries the current-speed property and attempts to use it to register the custom_divisor property of the uart_port. However, if current-speed is not set, then this code will dereference a bad pointer. The fix is to only set custom_divisor when a current-speed property appears in the device tree.

---
 drivers/serial/of_serial.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/serial/of_serial.c +3 -1
index a64d858..2efb892 100644
@@ -56,7 +56,9 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,
 	port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
 		| UPF_FIXED_PORT;
 	port->dev = &ofdev->dev;
-	port->custom_divisor = *clk / (16 * (*spd));
+	/* If current-speed was set, then try not to change it. */
+	if (spd)
+		port->custom_divisor = *clk / (16 * (*spd));
 
 	return 0;
 }
Signature · 1 line
1.5.2.1
Acked-by on v1 1/3
#1 lore raw
Quoted 10 lines · John Linn

From: Stephen Neuendorffer <[email protected]>

The of_serial driver queries the current-speed property and attempts to use it to register the custom_divisor property of the uart_port. However, if current-speed is not set, then this code will dereference a bad pointer. The fix is to only set custom_divisor when a current-speed property appears in the device tree.

This looks correct and appropriate to me.

Josh/Arnd, could either of you pick this up?

Cheers,
g.

Quoted 29 lines

---

  drivers/serial/of_serial.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index a64d858..2efb892 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -56,7 +56,9 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,

        port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
                | UPF_FIXED_PORT;
        port->dev = &ofdev->dev;
 -       port->custom_divisor = *clk / (16 * (*spd));
 +       /* If current-speed was set, then try not to change it. */
 +       if (spd)

+ port->custom_divisor = *clk / (16 * (*spd));

        return 0;

}
--
1.5.2.1

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
Acked-by
#2 lore raw
Quoted 9 lines · On Thu, 20 Mar 2008 17:58:07 -0600 "Grant Likely" <[email protected]>…
Quoted 8 lines · John Linn

From: Stephen Neuendorffer <[email protected]>

The of_serial driver queries the current-speed property and attempts to use it to register the custom_divisor property of the uart_port. However, if current-speed is not set, then this code will dereference a bad pointer. The fix is to only set custom_divisor when a current-speed property appears in the device tree.

Quoted 6 lines
Quoted 2 lines

This looks correct and appropriate to me.

Agreed.

Quoted 1 line

Josh/Arnd, could either of you pick this up?

Arnd, can you send this on to Andrew? Or if you are busy I can.

josh

Quoted 32 lines
Quoted 29 lines

---

  drivers/serial/of_serial.c |    4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index a64d858..2efb892 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -56,7 +56,9 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,

        port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
                | UPF_FIXED_PORT;
        port->dev = &ofdev->dev;
 -       port->custom_divisor = *clk / (16 * (*spd));
 +       /* If current-speed was set, then try not to change it. */
 +       if (spd)

+ port->custom_divisor = *clk / (16 * (*spd));

        return 0;

}
--
1.5.2.1

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev