Patchwork serial: mpc52xx_uart: fix null pointer dereference

login
register
mail settings
Submitter Anatolij Gustschin
Date May 4, 2010, 10:18 p.m.
Message ID <1273011539-13994-1-git-send-email-agust@denx.de>
Download mbox | patch
Permalink /patch/51637/
State Accepted, archived
Delegated to: Grant Likely
Headers show

Comments

Anatolij Gustschin - May 4, 2010, 10:18 p.m.
Commit 6acc6833510db8f72b5ef343296d97480555fda9
introduced NULL pointer dereference and kernel crash
on ppc32 machines while booting. Fix this bug now.

Reported-by: Leonardo Chiquitto <leonardo.lists@gmail.com>
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 drivers/serial/mpc52xx_uart.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Leonardo Chiquitto - May 5, 2010, 12:40 p.m.
On Tue, May 4, 2010 at 7:18 PM, Anatolij Gustschin <agust@denx.de> wrote:
> Commit 6acc6833510db8f72b5ef343296d97480555fda9
> introduced NULL pointer dereference and kernel crash
> on ppc32 machines while booting. Fix this bug now.
>
> Reported-by: Leonardo Chiquitto <leonardo.lists@gmail.com>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  drivers/serial/mpc52xx_uart.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
> index a176ab4..02469c3 100644
> --- a/drivers/serial/mpc52xx_uart.c
> +++ b/drivers/serial/mpc52xx_uart.c
> @@ -1467,7 +1467,7 @@ mpc52xx_uart_init(void)
>        /*
>         * Map the PSC FIFO Controller and init if on MPC512x.
>         */
> -       if (psc_ops->fifoc_init) {
> +       if (psc_ops && psc_ops->fifoc_init) {
>                ret = psc_ops->fifoc_init();
>                if (ret)
>                        return ret;
> --
> 1.7.0.4

Thanks for the quick fix, Anatolij. I just tested it and confirm it resolves
the problem.

Leonardo
Grant Likely - May 9, 2010, 10:04 p.m.
On Wed, May 5, 2010 at 12:18 AM, Anatolij Gustschin <agust@denx.de> wrote:
> Commit 6acc6833510db8f72b5ef343296d97480555fda9
> introduced NULL pointer dereference and kernel crash
> on ppc32 machines while booting. Fix this bug now.
>
> Reported-by: Leonardo Chiquitto <leonardo.lists@gmail.com>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>

Thanks for being so quick to pick up on this Anatolij.  I've been
traveling and not able to respond to stuff.  I see that Greg has
already picked this up (thanks Greg!), but FWIW:

Acked-by: Grant Likely <grant.likely@secretlab.ca>

Actually, now that I look, this fix needs to go into Linus' tree right
away (not just linux-next) since the offending patch went in during
the 2.6.34 merge window.

Greg, I can either pick this up and push it out to Linus tomorrow, or
let you do it.  Whichever you prefer.  Let me know so I don't cause
conflicts in your tree.

On another note, this patch isn't actually the right fix, but that's
because this driver is such a horribly bad example of handling private
data that doing the right thing requires some re-architecting.  The
driver should not need any of that extra code in the module_init hook.
 For now this is the best thing to do, but I'll dig into it tomorrow
and see if I can churn out a patch to fix it properly for the 2.6.35
merge window.

Cheers and thanks,
g.

> ---
>  drivers/serial/mpc52xx_uart.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
> index a176ab4..02469c3 100644
> --- a/drivers/serial/mpc52xx_uart.c
> +++ b/drivers/serial/mpc52xx_uart.c
> @@ -1467,7 +1467,7 @@ mpc52xx_uart_init(void)
>        /*
>         * Map the PSC FIFO Controller and init if on MPC512x.
>         */
> -       if (psc_ops->fifoc_init) {
> +       if (psc_ops && psc_ops->fifoc_init) {
>                ret = psc_ops->fifoc_init();
>                if (ret)
>                        return ret;
> --
> 1.7.0.4
>
>
gregkh@suse.de - May 10, 2010, 4:25 p.m.
On Mon, May 10, 2010 at 12:04:30AM +0200, Grant Likely wrote:
> On Wed, May 5, 2010 at 12:18 AM, Anatolij Gustschin <agust@denx.de> wrote:
> > Commit 6acc6833510db8f72b5ef343296d97480555fda9
> > introduced NULL pointer dereference and kernel crash
> > on ppc32 machines while booting. Fix this bug now.
> >
> > Reported-by: Leonardo Chiquitto <leonardo.lists@gmail.com>
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> 
> Thanks for being so quick to pick up on this Anatolij.  I've been
> traveling and not able to respond to stuff.  I see that Greg has
> already picked this up (thanks Greg!), but FWIW:
> 
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
> 
> Actually, now that I look, this fix needs to go into Linus' tree right
> away (not just linux-next) since the offending patch went in during
> the 2.6.34 merge window.
> 
> Greg, I can either pick this up and push it out to Linus tomorrow, or
> let you do it.  Whichever you prefer.  Let me know so I don't cause
> conflicts in your tree.

I have 2 other tty/serial fixes to go to Linus for .34 along with this
one, so I'll be glad to send it to him.  I've added your ack to the
patch.

thanks,

greg k-h
Grant Likely - May 10, 2010, 8:46 p.m.
On Mon, May 10, 2010 at 6:25 PM, Greg KH <gregkh@suse.de> wrote:
> On Mon, May 10, 2010 at 12:04:30AM +0200, Grant Likely wrote:
>> Greg, I can either pick this up and push it out to Linus tomorrow, or
>> let you do it.  Whichever you prefer.  Let me know so I don't cause
>> conflicts in your tree.
>
> I have 2 other tty/serial fixes to go to Linus for .34 along with this
> one, so I'll be glad to send it to him.  I've added your ack to the
> patch.

Perfect.  Thanks Greg.

g.

Patch

diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index a176ab4..02469c3 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -1467,7 +1467,7 @@  mpc52xx_uart_init(void)
 	/*
 	 * Map the PSC FIFO Controller and init if on MPC512x.
 	 */
-	if (psc_ops->fifoc_init) {
+	if (psc_ops && psc_ops->fifoc_init) {
 		ret = psc_ops->fifoc_init();
 		if (ret)
 			return ret;