From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound2-dub-R.bigfish.com (outbound-dub.frontbridge.com [213.199.154.16]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.bigfish.com", Issuer "*.bigfish.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D1FA4DE0F6 for ; Thu, 3 Apr 2008 03:52:21 +1100 (EST) From: John Linn To: linuxppc-dev@ozlabs.org, grant.likely@secretlab.ca Subject: [PATCH 1/3][POWERPC][V2] of_serial: Fix possible null dereference. Date: Wed, 2 Apr 2008 09:52:13 -0700 Message-Id: <20080402165216.8FD2BC9807F@mail21-dub.bigfish.com> Cc: John Linn List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Stephen Neuendorffer 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 Signed-off-by: John Linn --- 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