Skip to contentSkip to conversation

serial: samsung: protect NULL dereference of clock name

PATCH New Kyoungil Kim 4 participants 5 messages May 30, 2012 – Jun 20, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: samsung: protect NULL dereference of clock name

From: KeyYoung Park <[email protected]>

When priting the serial clock source, if clock source name is null, kernel reference NULL point.

---
 drivers/tty/serial/samsung.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/tty/serial/samsung.c +2 -1
index ea76b40..77484e0 100644
@@ -1160,7 +1160,8 @@ static ssize_t s3c24xx_serial_show_clksrc(struct device *dev,
 	struct uart_port *port = s3c24xx_dev_to_port(dev);
 	struct s3c24xx_uart_port *ourport = to_ourport(port);
 
-	return snprintf(buf, PAGE_SIZE, "* %s\n", ourport->baudclk->name);
+	return snprintf(buf, PAGE_SIZE, "* %s\n",
+			ourport->baudclk->name ?: "(null)");
 }
 
 static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc, NULL);
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 serial: samsung: protect NULL dereference of clock name

Hi Kim,

Quoted 5 lines · Kyoungil Kim

From: KeyYoung Park <[email protected]>

When priting the serial clock source, if clock source name is null, kernel reference NULL point.

Could you help me understand why is that NULL ? Or the crash that you saw.

#2 lore raw

PATCH 1/1 serial: samsung: protect NULL dereference of clock name

Quoted 8 lines · Shubhrajyoti Datta

Hi Kim,

Quoted 5 lines · Kyoungil Kim

From: KeyYoung Park <[email protected]>

When priting the serial clock source, if clock source name is null, kernel reference NULL point.

Could you help me understand why is that NULL ? Or the crash that you saw.

When you want to see the serial clock source name like using cat command before you open the tty, You can see the kernel crash.
I know this is not normal scenario.
This patch just prevents the kernel panic.

#3 lore raw

PATCH 1/1 serial: samsung: protect NULL dereference of clock name

In reply to Kyoungil Kim
Quoted 9 lines · Kyoungil Kim

From: KeyYoung Park <[email protected]>

When priting the serial clock source, if clock source name is null, kernel reference NULL point.

(Cc'ed Greg)

Greg, could you please pick this up?

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <[email protected]>, Senior Engineer, SW Solution Development Team, Samsung Electronics Co., Ltd.

Quoted 22 lines
---
 drivers/tty/serial/samsung.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/tty/serial/samsung.c +2 -1
index ea76b40..77484e0 100644
@@ -1160,7 +1160,8 @@ static ssize_t s3c24xx_serial_show_clksrc(struct
 device *dev,
 	struct uart_port *port = s3c24xx_dev_to_port(dev);
 	struct s3c24xx_uart_port *ourport = to_ourport(port);
 
-	return snprintf(buf, PAGE_SIZE, "* %s\n", ourport->baudclk->name);
+	return snprintf(buf, PAGE_SIZE, "* %s\n",
+			ourport->baudclk->name ?: "(null)");
 }
 

static DEVICE_ATTR(clock_source, S_IRUGO, s3c24xx_serial_show_clksrc,
NULL);
--
1.7.1

maintainer
#4 lore raw

PATCH 1/1 serial: samsung: protect NULL dereference of clock name

Quoted 11 lines · Kukjin Kim
Quoted 9 lines · Kyoungil Kim

From: KeyYoung Park <[email protected]>

When priting the serial clock source, if clock source name is null, kernel reference NULL point.

Quoted 5 lines

(Cc'ed Greg)

Greg, could you please pick this up?

Already have, thanks.

greg k-h