* [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-after-unmap
@ 2014-04-29 1:31 Scott Wood
2014-04-29 4:04 ` Gang.Liu
0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2014-04-29 1:31 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Scott Wood, Liu Gang
Several of the error paths from fsl_rio_setup are missing error
messages.
Worse, fsl_rio_setup initializes several global pointers and does not
NULL them out after freeing/unmapping on error. This caused
fsl_rio_mcheck_exception() to crash when accessing rio_regs_win which
was non-NULL but had been unmapped.
Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Liu Gang <Gang.Liu@freescale.com>
---
Liu Gang, are you sure all of these error conditions are fatal? Why
does the rio driver fail if rmu is not present (e.g. on t4240)?
---
arch/powerpc/sysdev/fsl_rio.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index cf2b084..c04b718 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -391,8 +391,10 @@ int fsl_rio_setup(struct platform_device *dev)
ops->get_inb_message = fsl_get_inb_message;
rmu_node = of_parse_phandle(dev->dev.of_node, "fsl,srio-rmu-handle", 0);
- if (!rmu_node)
+ if (!rmu_node) {
+ dev_err(&dev->dev, "No valid fsl,srio-rmu-handle property\n");
goto err_rmu;
+ }
rc = of_address_to_resource(rmu_node, 0, &rmu_regs);
if (rc) {
dev_err(&dev->dev, "Can't get %s property 'reg'\n",
@@ -413,6 +415,7 @@ int fsl_rio_setup(struct platform_device *dev)
/*set up doobell node*/
np = of_find_compatible_node(NULL, NULL, "fsl,srio-dbell-unit");
if (!np) {
+ dev_err(&dev->dev, "No fsl,srio-dbell-unit node\n");
rc = -ENODEV;
goto err_dbell;
}
@@ -441,6 +444,7 @@ int fsl_rio_setup(struct platform_device *dev)
/*set up port write node*/
np = of_find_compatible_node(NULL, NULL, "fsl,srio-port-write-unit");
if (!np) {
+ dev_err(&dev->dev, "No fsl,srio-port-write-unit node\n");
rc = -ENODEV;
goto err_pw;
}
@@ -633,14 +637,18 @@ int fsl_rio_setup(struct platform_device *dev)
return 0;
err:
kfree(pw);
+ pw = NULL;
err_pw:
kfree(dbell);
+ dbell = NULL;
err_dbell:
iounmap(rmu_regs_win);
+ rmu_regs_win = NULL;
err_rmu:
kfree(ops);
err_ops:
iounmap(rio_regs_win);
+ rio_regs_win = NULL;
err_rio_regs:
return rc;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-after-unmap
2014-04-29 1:31 [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-after-unmap Scott Wood
@ 2014-04-29 4:04 ` Gang.Liu
2014-04-29 17:12 ` Scott Wood
0 siblings, 1 reply; 4+ messages in thread
From: Gang.Liu @ 2014-04-29 4:04 UTC (permalink / raw)
To: Scott Wood, linuxppc-dev@lists.ozlabs.org
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Tuesday, April 29, 2014 9:32 AM
> To: linuxppc-dev@lists.ozlabs.org
> Cc: Wood Scott-B07421; Liu Gang-B34182
> Subject: [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-
> after-unmap
>=20
> Several of the error paths from fsl_rio_setup are missing error messages.
>=20
> Worse, fsl_rio_setup initializes several global pointers and does not
> NULL them out after freeing/unmapping on error. This caused
> fsl_rio_mcheck_exception() to crash when accessing rio_regs_win which was
> non-NULL but had been unmapped.
>=20
> Signed-off-by: Scott Wood <scottwood@freescale.com>
> Cc: Liu Gang <Gang.Liu@freescale.com>
> ---
> Liu Gang, are you sure all of these error conditions are fatal? Why does
> the rio driver fail if rmu is not present (e.g. on t4240)?
Hi Scott, I think the errors you modified in the patch are serious and shou=
ld
be fixed. Thanks very much!
And in fact, the rio driver can be used just for the submodule of the SRIO:=
RMU.
It should be used with arch/powerpc/sysdev/fsl_rmu.c and there should have =
the
RMU module.
The fsl_rio.c implements some basic and needed works to support the RMU run=
ning well.
In addition, could you please help to apply the following patch:
http://patchwork.ozlabs.org/patch/337810/
Thanks!
Liu Gang =20
> ---
> arch/powerpc/sysdev/fsl_rio.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-after-unmap
2014-04-29 4:04 ` Gang.Liu
@ 2014-04-29 17:12 ` Scott Wood
2014-04-30 2:58 ` Gang.Liu
0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2014-04-29 17:12 UTC (permalink / raw)
To: Liu Gang-B34182; +Cc: linuxppc-dev@lists.ozlabs.org
On Mon, 2014-04-28 at 23:04 -0500, Liu Gang-B34182 wrote:
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Tuesday, April 29, 2014 9:32 AM
> > To: linuxppc-dev@lists.ozlabs.org
> > Cc: Wood Scott-B07421; Liu Gang-B34182
> > Subject: [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-
> > after-unmap
> >
> > Several of the error paths from fsl_rio_setup are missing error messages.
> >
> > Worse, fsl_rio_setup initializes several global pointers and does not
> > NULL them out after freeing/unmapping on error. This caused
> > fsl_rio_mcheck_exception() to crash when accessing rio_regs_win which was
> > non-NULL but had been unmapped.
> >
> > Signed-off-by: Scott Wood <scottwood@freescale.com>
> > Cc: Liu Gang <Gang.Liu@freescale.com>
> > ---
> > Liu Gang, are you sure all of these error conditions are fatal? Why does
> > the rio driver fail if rmu is not present (e.g. on t4240)?
>
> Hi Scott, I think the errors you modified in the patch are serious and should
> be fixed. Thanks very much!
> And in fact, the rio driver can be used just for the submodule of the SRIO: RMU.
> It should be used with arch/powerpc/sysdev/fsl_rmu.c and there should have the
> RMU module.
> The fsl_rio.c implements some basic and needed works to support the RMU running well.
I don't quite follow -- is it expected that rio can work without rmu, or
not? As is, fsl_rio_setup() will error out if it doesn't find an
fsl,srio-rmu-handle property.
> In addition, could you please help to apply the following patch:
>
> http://patchwork.ozlabs.org/patch/337810/
Yes, I'll apply it when I do my next batch of patch applications.
-Scott
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-after-unmap
2014-04-29 17:12 ` Scott Wood
@ 2014-04-30 2:58 ` Gang.Liu
0 siblings, 0 replies; 4+ messages in thread
From: Gang.Liu @ 2014-04-30 2:58 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev@lists.ozlabs.org
DQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IFdvb2QgU2NvdHQtQjA3NDIx
DQo+IFNlbnQ6IFdlZG5lc2RheSwgQXByaWwgMzAsIDIwMTQgMToxMyBBTQ0KPiBUbzogTGl1IEdh
bmctQjM0MTgyDQo+IENjOiBsaW51eHBwYy1kZXZAbGlzdHMub3psYWJzLm9yZw0KPiBTdWJqZWN0
OiBSZTogW1BBVENIXSBwb3dlcnBjL2ZzbC1yaW86IEZpeCBmc2xfcmlvX3NldHVwIGVycm9yIHBh
dGhzIGFuZA0KPiB1c2UtYWZ0ZXItdW5tYXANCj4gDQo+IE9uIE1vbiwgMjAxNC0wNC0yOCBhdCAy
MzowNCAtMDUwMCwgTGl1IEdhbmctQjM0MTgyIHdyb3RlOg0KPiA+ID4gLS0tLS1PcmlnaW5hbCBN
ZXNzYWdlLS0tLS0NCj4gPiA+IEZyb206IFdvb2QgU2NvdHQtQjA3NDIxDQo+ID4gPiBTZW50OiBU
dWVzZGF5LCBBcHJpbCAyOSwgMjAxNCA5OjMyIEFNDQo+ID4gPiBUbzogbGludXhwcGMtZGV2QGxp
c3RzLm96bGFicy5vcmcNCj4gPiA+IENjOiBXb29kIFNjb3R0LUIwNzQyMTsgTGl1IEdhbmctQjM0
MTgyDQo+ID4gPiBT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BybXUuDQpUaGF0J3Mgd2h5IHRoZSBkcml2
ZXJzIGNhbm5vdCBqdXN0IGhhdmUgYSBzdWNoIGFzIHJtdV9zZXR1cCgpIHRvIHBhcnNlDQpmc2ws
c3Jpby1ybXUtaGFuZGxlIHByb3BlcnR5Lg0KDQpUaGFua3MsDQpMaXUgR2FuZw0KIA0K
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-30 2:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-29 1:31 [PATCH] powerpc/fsl-rio: Fix fsl_rio_setup error paths and use-after-unmap Scott Wood
2014-04-29 4:04 ` Gang.Liu
2014-04-29 17:12 ` Scott Wood
2014-04-30 2:58 ` Gang.Liu
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).