Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6dae1421 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Paul Mundt
Browse files

serial: sh-sci: Fix probe error paths



When probing fails, the driver must not try to cleanup resources that
have not been initialized. Fix this.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 37778088
Loading
Loading
Loading
Loading
+23 −13
Original line number Original line Diff line number Diff line
@@ -2179,6 +2179,16 @@ static int __devinit sci_init_single(struct platform_device *dev,
	return 0;
	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
#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
static void serial_console_putchar(struct uart_port *port, int ch)
static void serial_console_putchar(struct uart_port *port, int ch)
{
{
@@ -2360,14 +2370,10 @@ static int sci_remove(struct platform_device *dev)
	cpufreq_unregister_notifier(&port->freq_transition,
	cpufreq_unregister_notifier(&port->freq_transition,
				    CPUFREQ_TRANSITION_NOTIFIER);
				    CPUFREQ_TRANSITION_NOTIFIER);


	sci_free_gpios(port);

	uart_remove_one_port(&sci_uart_driver, &port->port);
	uart_remove_one_port(&sci_uart_driver, &port->port);


	clk_put(port->iclk);
	sci_cleanup_single(port);
	clk_put(port->fclk);


	pm_runtime_disable(&dev->dev);
	return 0;
	return 0;
}
}


@@ -2392,7 +2398,13 @@ static int __devinit sci_probe_single(struct platform_device *dev,
	if (ret)
	if (ret)
		return 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)
static int __devinit sci_probe(struct platform_device *dev)
@@ -2413,24 +2425,22 @@ static int __devinit sci_probe(struct platform_device *dev)


	ret = sci_probe_single(dev, dev->id, p, sp);
	ret = sci_probe_single(dev, dev->id, p, sp);
	if (ret)
	if (ret)
		goto err_unreg;
		return ret;


	sp->freq_transition.notifier_call = sci_notifier;
	sp->freq_transition.notifier_call = sci_notifier;


	ret = cpufreq_register_notifier(&sp->freq_transition,
	ret = cpufreq_register_notifier(&sp->freq_transition,
					CPUFREQ_TRANSITION_NOTIFIER);
					CPUFREQ_TRANSITION_NOTIFIER);
	if (unlikely(ret < 0))
	if (unlikely(ret < 0)) {
		goto err_unreg;
		sci_cleanup_single(sp);
		return ret;
	}


#ifdef CONFIG_SH_STANDARD_BIOS
#ifdef CONFIG_SH_STANDARD_BIOS
	sh_bios_gdb_detach();
	sh_bios_gdb_detach();
#endif
#endif


	return 0;
	return 0;

err_unreg:
	sci_remove(dev);
	return ret;
}
}


static int sci_suspend(struct device *dev)
static int sci_suspend(struct device *dev)