* [PATCH 1/2] serial: sh-sci: Fix probe error paths
@ 2012-06-12 22:28 Laurent Pinchart
2012-06-12 22:28 ` [PATCH 2/2] serial: sh-sci: Make probe fail for ports that exceed the maximum count Laurent Pinchart
2012-06-13 1:36 ` [PATCH 1/2] serial: sh-sci: Fix probe error paths Paul Mundt
0 siblings, 2 replies; 3+ messages in thread
From: Laurent Pinchart @ 2012-06-12 22:28 UTC (permalink / raw)
To: Paul Mundt; +Cc: linux-serial, linux-sh
When probing fails, the driver must not try to cleanup resources that
have not been initialized. Fix this.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/tty/serial/sh-sci.c | 36 +++++++++++++++++++++++-------------
1 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 3158e17..a779663 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2140,6 +2140,16 @@ static int __devinit sci_init_single(struct platform_device *dev,
return 0;
}
+static void sci_cleanup_single(struct sci_port *port)
+{
+ sci_free_gpios(port);
+
+ clk_put(port->iclk);
+ clk_put(port->fclk);
+
+ pm_runtime_disable(port->port.dev);
+}
+
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
static void serial_console_putchar(struct uart_port *port, int ch)
{
@@ -2321,14 +2331,10 @@ static int sci_remove(struct platform_device *dev)
cpufreq_unregister_notifier(&port->freq_transition,
CPUFREQ_TRANSITION_NOTIFIER);
- sci_free_gpios(port);
-
uart_remove_one_port(&sci_uart_driver, &port->port);
- clk_put(port->iclk);
- clk_put(port->fclk);
+ sci_cleanup_single(port);
- pm_runtime_disable(&dev->dev);
return 0;
}
@@ -2353,7 +2359,13 @@ static int __devinit sci_probe_single(struct platform_device *dev,
if (ret)
return ret;
- return uart_add_one_port(&sci_uart_driver, &sciport->port);
+ ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
+ if (ret) {
+ sci_cleanup_single(sciport);
+ return ret;
+ }
+
+ return 0;
}
static int __devinit sci_probe(struct platform_device *dev)
@@ -2374,24 +2386,22 @@ static int __devinit sci_probe(struct platform_device *dev)
ret = sci_probe_single(dev, dev->id, p, sp);
if (ret)
- goto err_unreg;
+ return ret;
sp->freq_transition.notifier_call = sci_notifier;
ret = cpufreq_register_notifier(&sp->freq_transition,
CPUFREQ_TRANSITION_NOTIFIER);
- if (unlikely(ret < 0))
- goto err_unreg;
+ if (unlikely(ret < 0)) {
+ sci_cleanup_single(sp);
+ return ret;
+ }
#ifdef CONFIG_SH_STANDARD_BIOS
sh_bios_gdb_detach();
#endif
return 0;
-
-err_unreg:
- sci_remove(dev);
- return ret;
}
static int sci_suspend(struct device *dev)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] serial: sh-sci: Make probe fail for ports that exceed the maximum count
2012-06-12 22:28 [PATCH 1/2] serial: sh-sci: Fix probe error paths Laurent Pinchart
@ 2012-06-12 22:28 ` Laurent Pinchart
2012-06-13 1:36 ` [PATCH 1/2] serial: sh-sci: Fix probe error paths Paul Mundt
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2012-06-12 22:28 UTC (permalink / raw)
To: Paul Mundt; +Cc: linux-serial, linux-sh
The driver supports a maximum number of ports configurable at compile
time. Make sure the probe() method fails when registering a port that
exceeds the maximum instead of returning success without registering the
port.
This fixes a crash at system suspend time, when the driver tried to
suspend a non-registered port using the UART core.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/tty/serial/sh-sci.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index a779663..55dada3 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2352,7 +2352,7 @@ static int __devinit sci_probe_single(struct platform_device *dev,
index+1, SCI_NPORTS);
dev_notice(&dev->dev, "Consider bumping "
"CONFIG_SERIAL_SH_SCI_NR_UARTS!\n");
- return 0;
+ return -EINVAL;
}
ret = sci_init_single(dev, sciport, index, p);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] serial: sh-sci: Fix probe error paths
2012-06-12 22:28 [PATCH 1/2] serial: sh-sci: Fix probe error paths Laurent Pinchart
2012-06-12 22:28 ` [PATCH 2/2] serial: sh-sci: Make probe fail for ports that exceed the maximum count Laurent Pinchart
@ 2012-06-13 1:36 ` Paul Mundt
1 sibling, 0 replies; 3+ messages in thread
From: Paul Mundt @ 2012-06-13 1:36 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linux-serial, linux-sh
On Wed, Jun 13, 2012 at 12:28:23AM +0200, Laurent Pinchart wrote:
> When probing fails, the driver must not try to cleanup resources that
> have not been initialized. Fix this.
On Wed, Jun 13, 2012 at 12:28:24AM +0200, Laurent Pinchart wrote:
> The driver supports a maximum number of ports configurable at compile
> time. Make sure the probe() method fails when registering a port that
> exceeds the maximum instead of returning success without registering the
> port.
>
> This fixes a crash at system suspend time, when the driver tried to
> suspend a non-registered port using the UART core.
Both applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-13 1:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-12 22:28 [PATCH 1/2] serial: sh-sci: Fix probe error paths Laurent Pinchart
2012-06-12 22:28 ` [PATCH 2/2] serial: sh-sci: Make probe fail for ports that exceed the maximum count Laurent Pinchart
2012-06-13 1:36 ` [PATCH 1/2] serial: sh-sci: Fix probe error paths Paul Mundt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).