Messages in this thread | | | From | Kees Cook <> | Date | Tue, 22 Jan 2019 14:55:16 +1300 | Subject | Re: [PATCH] pstore/ram: Add ramoops_register_dummy failure process |
| |
On Mon, Jan 21, 2019 at 9:42 PM Yue Hu <huyue2@yulong.com> wrote: > > From 0888dbf0e3ac4a6a8a6307e97d003e8deb9cc6db Mon Sep 17 00:00:00 2001 > From: Yue Hu <huyue2@yulong.com> > Date: Mon, 21 Jan 2019 14:30:19 +0800 > Subject: [PATCH] pstore/ram: Add ramoops_register_dummy failure process > > If create dummy/dummy_data failed, platform_driver_register() > could also return 0 which leads to successful ramoops_init(). > This logic is not reasonable, it should tell kernel ramoops is > failed. This change can also avoid duplicated ramoops dummy > unregister and remove some unnecessary messages too.
No, this is working as intended (perhaps this code needs better comments). If there is no module parameters, they may yet still be a custom platform driver (see drivers/platform/chrome/chromeos_pstore.c), or device tree entry (see Documentation/admin-guide/ramoops.rst).
-Kees
> > Signed-off-by: Yue Hu <huyue2@yulong.com> > --- > fs/pstore/ram.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c > index 64a51cd..7fb97aa 100644 > --- a/fs/pstore/ram.c > +++ b/fs/pstore/ram.c > @@ -905,7 +905,7 @@ static inline void ramoops_unregister_dummy(void) > dummy_data = NULL; > } > > -static void __init ramoops_register_dummy(void) > +static int __init ramoops_register_dummy(void) > { > /* > * Prepare a dummy platform data structure to carry the module > @@ -913,15 +913,13 @@ static void __init ramoops_register_dummy(void) > * parameters, and we can skip this. > */ > if (!mem_size) > - return; > + return -EINVAL; > > pr_info("using module parameters\n"); > > dummy_data = kzalloc(sizeof(*dummy_data), GFP_KERNEL); > - if (!dummy_data) { > - pr_info("could not allocate pdata\n"); > - return; > - } > + if (!dummy_data) > + return -ENOMEM; > > dummy_data->mem_size = mem_size; > dummy_data->mem_address = mem_address; > @@ -942,18 +940,20 @@ static void __init ramoops_register_dummy(void) > dummy = platform_device_register_data(NULL, "ramoops", -1, > dummy_data, sizeof(struct ramoops_platform_data)); > if (IS_ERR(dummy)) { > - pr_info("could not create platform device: %ld\n", > - PTR_ERR(dummy)); > - dummy = NULL; > ramoops_unregister_dummy(); > + return PTR_ERR(dummy); > } > + return 0; > } > > static int __init ramoops_init(void) > { > int ret; > > - ramoops_register_dummy(); > + ret = ramoops_register_dummy(); > + if (ret) > + return ret; > + > ret = platform_driver_register(&ramoops_driver); > if (ret != 0) > ramoops_unregister_dummy(); > -- > 1.9.1 > > > >
-- Kees Cook
| |