lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMGffEm1FJpA5B9iyiieeRVYu=Te+wanauaVBBfx2YFZUozGEw@mail.gmail.com>
Date:   Wed, 21 Jun 2023 12:10:38 +0200
From:   Jinpu Wang <jinpu.wang@...os.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
        Ivan Orlov <ivan.orlov0322@...il.com>,
        "Md. Haris Iqbal" <haris.iqbal@...os.com>,
        Jens Axboe <axboe@...nel.dk>
Subject: Re: [PATCH 1/4] block/rnbd: make all 'class' structures const

On Tue, Jun 20, 2023 at 8:01 PM Greg Kroah-Hartman
<gregkh@...uxfoundation.org> wrote:
>
> From: Ivan Orlov <ivan.orlov0322@...il.com>
>
> Now that the driver core allows for struct class to be in read-only
> memory, making all 'class' structures to be declared at build time
> placing them into read-only memory, instead of having to be dynamically
> allocated at load time.
>
> Cc: "Md. Haris Iqbal" <haris.iqbal@...os.com>
> Cc: Jack Wang <jinpu.wang@...os.com>
> Cc: Jens Axboe <axboe@...nel.dk>
> Cc: linux-block@...r.kernel.org
> Suggested-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Signed-off-by: Ivan Orlov <ivan.orlov0322@...il.com>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
lgtm.
Acked-by: Jack Wang <jinpu.wang@...os.com>
> ---
>  drivers/block/rnbd/rnbd-clt-sysfs.c | 20 +++++++++++---------
>  drivers/block/rnbd/rnbd-srv-sysfs.c | 22 ++++++++++++----------
>  2 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
> index 8c6087949794..e84abac04f4f 100644
> --- a/drivers/block/rnbd/rnbd-clt-sysfs.c
> +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
> @@ -24,7 +24,9 @@
>  #include "rnbd-clt.h"
>
>  static struct device *rnbd_dev;
> -static struct class *rnbd_dev_class;
> +static const struct class rnbd_dev_class = {
> +       .name = "rnbd_client",
> +};
>  static struct kobject *rnbd_devs_kobj;
>
>  enum {
> @@ -646,11 +648,11 @@ int rnbd_clt_create_sysfs_files(void)
>  {
>         int err;
>
> -       rnbd_dev_class = class_create("rnbd-client");
> -       if (IS_ERR(rnbd_dev_class))
> -               return PTR_ERR(rnbd_dev_class);
> +       err = class_register(&rnbd_dev_class);
> +       if (err)
> +               return err;
>
> -       rnbd_dev = device_create_with_groups(rnbd_dev_class, NULL,
> +       rnbd_dev = device_create_with_groups(&rnbd_dev_class, NULL,
>                                               MKDEV(0, 0), NULL,
>                                               default_attr_groups, "ctl");
>         if (IS_ERR(rnbd_dev)) {
> @@ -666,9 +668,9 @@ int rnbd_clt_create_sysfs_files(void)
>         return 0;
>
>  dev_destroy:
> -       device_destroy(rnbd_dev_class, MKDEV(0, 0));
> +       device_destroy(&rnbd_dev_class, MKDEV(0, 0));
>  cls_destroy:
> -       class_destroy(rnbd_dev_class);
> +       class_unregister(&rnbd_dev_class);
>
>         return err;
>  }
> @@ -678,6 +680,6 @@ void rnbd_clt_destroy_sysfs_files(void)
>         sysfs_remove_group(&rnbd_dev->kobj, &default_attr_group);
>         kobject_del(rnbd_devs_kobj);
>         kobject_put(rnbd_devs_kobj);
> -       device_destroy(rnbd_dev_class, MKDEV(0, 0));
> -       class_destroy(rnbd_dev_class);
> +       device_destroy(&rnbd_dev_class, MKDEV(0, 0));
> +       class_unregister(&rnbd_dev_class);
>  }
> diff --git a/drivers/block/rnbd/rnbd-srv-sysfs.c b/drivers/block/rnbd/rnbd-srv-sysfs.c
> index d5d9267e1fa5..5e69c0112e23 100644
> --- a/drivers/block/rnbd/rnbd-srv-sysfs.c
> +++ b/drivers/block/rnbd/rnbd-srv-sysfs.c
> @@ -20,7 +20,9 @@
>  #include "rnbd-srv.h"
>
>  static struct device *rnbd_dev;
> -static struct class *rnbd_dev_class;
> +static const struct class rnbd_dev_class = {
> +       .name = "rnbd-server",
> +};
>  static struct kobject *rnbd_devs_kobj;
>
>  static void rnbd_srv_dev_release(struct kobject *kobj)
> @@ -215,12 +217,12 @@ int rnbd_srv_create_sysfs_files(void)
>  {
>         int err;
>
> -       rnbd_dev_class = class_create("rnbd-server");
> -       if (IS_ERR(rnbd_dev_class))
> -               return PTR_ERR(rnbd_dev_class);
> +       err = class_register(&rnbd_dev_class);
> +       if (err)
> +               return err;
>
> -       rnbd_dev = device_create(rnbd_dev_class, NULL,
> -                                 MKDEV(0, 0), NULL, "ctl");
> +       rnbd_dev = device_create(&rnbd_dev_class, NULL,
> +                                MKDEV(0, 0), NULL, "ctl");
>         if (IS_ERR(rnbd_dev)) {
>                 err = PTR_ERR(rnbd_dev);
>                 goto cls_destroy;
> @@ -234,9 +236,9 @@ int rnbd_srv_create_sysfs_files(void)
>         return 0;
>
>  dev_destroy:
> -       device_destroy(rnbd_dev_class, MKDEV(0, 0));
> +       device_destroy(&rnbd_dev_class, MKDEV(0, 0));
>  cls_destroy:
> -       class_destroy(rnbd_dev_class);
> +       class_unregister(&rnbd_dev_class);
>
>         return err;
>  }
> @@ -245,6 +247,6 @@ void rnbd_srv_destroy_sysfs_files(void)
>  {
>         kobject_del(rnbd_devs_kobj);
>         kobject_put(rnbd_devs_kobj);
> -       device_destroy(rnbd_dev_class, MKDEV(0, 0));
> -       class_destroy(rnbd_dev_class);
> +       device_destroy(&rnbd_dev_class, MKDEV(0, 0));
> +       class_unregister(&rnbd_dev_class);
>  }
> --
> 2.41.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ