[PATCH 1/3] [POWERPC] of_serial: Fix possible null dereference.

Subsystems: the rest

STALE6793d

3 messages, 3 authors, 2008-03-21 · open the first message on its own page

[PATCH 1/3] [POWERPC] of_serial: Fix possible null dereference.

From: John Linn <hidden>
Date: 2008-03-20 14:44:07

From: Stephen Neuendorffer <redacted>

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.

Signed-off-by: Stephen Neuendorffer <redacted>
Signed-off-by: John Linn <redacted>
---
 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

Re: [PATCH 1/3] [POWERPC] of_serial: Fix possible null dereference.

From: Grant Likely <hidden>
Date: 2008-03-20 23:58:09

On Thu, Mar 20, 2008 at 8:43 AM, John Linn [off-list ref] wrote:
From: Stephen Neuendorffer <redacted>

 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.

 Signed-off-by: Stephen Neuendorffer [off-list ref]
 Signed-off-by: John Linn [off-list ref]
This looks correct and appropriate to me.

Acked-by: Grant Likely <redacted>

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

Cheers,
g.
 ---
  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
 Linuxppc-dev@ozlabs.org
 https://ozlabs.org/mailman/listinfo/linuxppc-dev


-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

Re: [PATCH 1/3] [POWERPC] of_serial: Fix possible null dereference.

From: Josh Boyer <hidden>
Date: 2008-03-21 01:42:44

On Thu, 20 Mar 2008 17:58:07 -0600
"Grant Likely" [off-list ref] wrote:
On Thu, Mar 20, 2008 at 8:43 AM, John Linn [off-list ref] wrote:
quoted
From: Stephen Neuendorffer <redacted>

 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.

 Signed-off-by: Stephen Neuendorffer [off-list ref]
 Signed-off-by: John Linn [off-list ref]
This looks correct and appropriate to me.

Acked-by: Grant Likely <redacted>
Agreed.

Acked-by: Josh Boyer <redacted>
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
 ---
  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
 Linuxppc-dev@ozlabs.org
 https://ozlabs.org/mailman/listinfo/linuxppc-dev
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help