ramoops: update parameters only after successful init
PATCH 1/1 ramoops: update parameters only after successful init
If a platform device exists on the system, but ramoops fails to attach to it, the module parameters are overridden before ramoops can fall back and try to use passed module parameters. Move update to end of init routine.
--- drivers/char/ramoops.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
drivers/char/ramoops.c +9 -8
@@ -147,14 +147,6 @@ static int __init ramoops_probe(struct platform_device *pdev) cxt->phys_addr = pdata->mem_address; cxt->record_size = pdata->record_size; cxt->dump_oops = pdata->dump_oops; -/* -* Update the module parameter variables as well so they are visible -* through /sys/module/ramoops/parameters/ -*/ - mem_size = pdata->mem_size; - mem_address = pdata->mem_address; - record_size = pdata->record_size; - dump_oops = pdata->dump_oops;if (!request_mem_region (cxt->phys_addr, cxt->size,"ramoops" )) {pr_err ("request mem region failed\n" );
@@ -175,6 +167,15 @@ static int __init ramoops_probe(struct platform_device *pdev) goto fail1; } +/* +* Update the module parameter variables as well so they are visible +* through /sys/module/ramoops/parameters/ +*/ + mem_size = pdata->mem_size; + mem_address = pdata->mem_address; + record_size = pdata->record_size; + dump_oops = pdata->dump_oops; +return 0 ; fail1:
Signature · 5 lines
1.7.5.4 -- Kees Cook @outflux.net
Quoted 3 lines · On Tue, 18 Oct 2011 11:01:27 -0700 Kees Cook <[email protected]> wrote:
If a platform device exists on the system, but ramoops fails to attach to it, the module parameters are overridden before ramoops can fall back and try to use passed module parameters. Move update to end of init routine.
Modifying the module paremeters in this way seems like a Wrong Thing To Do and a rather nasty hack.
I'd have thought that /sys/module/ramoops/parameters should reflect the options which were provided to the module and should not be modified by the kernel behind everyone's back.
If we wish to display the configuration which the driver acquired from the platform data then sure, add an interface to do that. But it's wrong to go and pretend that this is what the user provided to modprobe!