linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] microblaze: uartlite: avoid NULL pointer exception
@ 2012-08-08 18:44 Stephan Linz
  2012-08-21  6:34 ` Peter Crosthwaite
  0 siblings, 1 reply; 2+ messages in thread
From: Stephan Linz @ 2012-08-08 18:44 UTC (permalink / raw)
  To: monstr; +Cc: microblaze-uclinux, linux-kernel, Stephan Linz

'prop' is an pointer and can only be unset (NULL) after
prop = of_get_property() when it goes wrong.

Kernel oops in ulite_probe():

[    1.016645] uartlite 8fff0000.debug: failed to get alias id, errno -19
[    1.024246] Oops: kernel access of bad area, sig: 11
[    1.029733]  Registers dump: mode=27827D60
[    1.034362]  r1=C79113E0, r2=00000000, r3=00000000, r4=00000000
[    1.040918]  r5=C02E1E49, r6=C02D5918, r7=00000070, r8=000014C9
[    1.047475]  r9=000014C8, r10=000014C9, r11=00000006, r12=FFFFFFFC
[    1.054318]  r13=00000000, r14=C79114A0, r15=C0293BDC, r16=00000000
[    1.061261]  r17=C0293BE4, r18=FFFFFFFE, r19=C788BDC8, r20=00000000
[    1.068207]  r21=00000000, r22=FFFFFFED, r23=C788BDC0, r24=C033E840
[    1.075145]  r25=C033EEA4, r26=00000000, r27=00000000, r28=00000000
[    1.082086]  r29=00000000, r30=00000000, r31=C7824AC0, rPC=C0293BE4
[    1.089024]  msr=000046A2, ear=00000000, esr=00000872, fsr=C7827E08
[    1.096281] Kernel panic - not syncing: Attempted to kill init!

Now it is:

[    1.014924] uartlite 8fff0000.debug: failed to get alias id, errno -19
[    1.022543] uartlite 8fff0000.debug: failed to get port-number

Signed-off-by: Stephan Linz <linz@li-pro.net>
---
 drivers/tty/serial/uartlite.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index a276282..3cba732 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -589,9 +589,8 @@ static int __devinit ulite_probe(struct platform_device *pdev)
 		dev_warn(&pdev->dev, "failed to get alias id, errno %d\n", id);
 		/* Fall back to old port-number property */
 		prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
-		if (prop < 0) {
-			dev_warn(&pdev->dev,
-				"failed to get port-number, errno %d\n", prop);
+		if (!prop) {
+			dev_warn(&pdev->dev, "failed to get port-number\n");
 			id = -1;
 		} else
 			id = be32_to_cpup(prop);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] microblaze: uartlite: avoid NULL pointer exception
  2012-08-08 18:44 [PATCH] microblaze: uartlite: avoid NULL pointer exception Stephan Linz
@ 2012-08-21  6:34 ` Peter Crosthwaite
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Crosthwaite @ 2012-08-21  6:34 UTC (permalink / raw)
  To: Stephan Linz; +Cc: monstr, microblaze-uclinux, linux-kernel

On Thu, Aug 9, 2012 at 4:44 AM, Stephan Linz <linz@li-pro.net> wrote:
> 'prop' is an pointer and can only be unset (NULL) after
> prop = of_get_property() when it goes wrong.
>
> Kernel oops in ulite_probe():
>
> [    1.016645] uartlite 8fff0000.debug: failed to get alias id, errno -19
> [    1.024246] Oops: kernel access of bad area, sig: 11
> [    1.029733]  Registers dump: mode=27827D60
> [    1.034362]  r1=C79113E0, r2=00000000, r3=00000000, r4=00000000
> [    1.040918]  r5=C02E1E49, r6=C02D5918, r7=00000070, r8=000014C9
> [    1.047475]  r9=000014C8, r10=000014C9, r11=00000006, r12=FFFFFFFC
> [    1.054318]  r13=00000000, r14=C79114A0, r15=C0293BDC, r16=00000000
> [    1.061261]  r17=C0293BE4, r18=FFFFFFFE, r19=C788BDC8, r20=00000000
> [    1.068207]  r21=00000000, r22=FFFFFFED, r23=C788BDC0, r24=C033E840
> [    1.075145]  r25=C033EEA4, r26=00000000, r27=00000000, r28=00000000
> [    1.082086]  r29=00000000, r30=00000000, r31=C7824AC0, rPC=C0293BE4
> [    1.089024]  msr=000046A2, ear=00000000, esr=00000872, fsr=C7827E08
> [    1.096281] Kernel panic - not syncing: Attempted to kill init!
>
> Now it is:
>
> [    1.014924] uartlite 8fff0000.debug: failed to get alias id, errno -19
> [    1.022543] uartlite 8fff0000.debug: failed to get port-number
>
> Signed-off-by: Stephan Linz <linz@li-pro.net>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@petalogix.com>
Tested-by: Peter Crosthwaite <peter.crosthwaite@petalogix.com>

> ---
>  drivers/tty/serial/uartlite.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
> index a276282..3cba732 100644
> --- a/drivers/tty/serial/uartlite.c
> +++ b/drivers/tty/serial/uartlite.c
> @@ -589,9 +589,8 @@ static int __devinit ulite_probe(struct platform_device *pdev)
>                 dev_warn(&pdev->dev, "failed to get alias id, errno %d\n", id);
>                 /* Fall back to old port-number property */
>                 prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
> -               if (prop < 0) {
> -                       dev_warn(&pdev->dev,
> -                               "failed to get port-number, errno %d\n", prop);
> +               if (!prop) {
> +                       dev_warn(&pdev->dev, "failed to get port-number\n");
>                         id = -1;
>                 } else
>                         id = be32_to_cpup(prop);
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-21  6:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-08 18:44 [PATCH] microblaze: uartlite: avoid NULL pointer exception Stephan Linz
2012-08-21  6:34 ` Peter Crosthwaite

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).