public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: rnbd: add .release to rnbd_dev_ktype
@ 2025-04-27 15:48 Salah Triki
  2025-04-27 22:03 ` Jens Axboe
  2025-04-28  9:58 ` Jinpu Wang
  0 siblings, 2 replies; 5+ messages in thread
From: Salah Triki @ 2025-04-27 15:48 UTC (permalink / raw)
  To: Md. Haris Iqbal, Jack Wang, Jens Axboe, linux-block, linux-kernel
  Cc: salah.triki

Every ktype must provides a .release function that will be called after
the last kobject_put.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/block/rnbd/rnbd-clt-sysfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
index 6ea7c12e3a87..144aea1466a4 100644
--- a/drivers/block/rnbd/rnbd-clt-sysfs.c
+++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
@@ -475,9 +475,17 @@ void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
 	}
 }
 
+static void rnbd_dev_release(struct kobject *kobj)
+{
+	struct rnbd_clt_dev *dev = container_of(kobj, struct rnbd_clt_dev, kobj);
+
+	kfree(dev);
+}
+
 static const struct kobj_type rnbd_dev_ktype = {
 	.sysfs_ops      = &kobj_sysfs_ops,
 	.default_groups = rnbd_dev_groups,
+	.release	= rnbd_dev_release,
 };
 
 static int rnbd_clt_add_dev_kobj(struct rnbd_clt_dev *dev)
-- 
2.43.0


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

* Re: [PATCH] block: rnbd: add .release to rnbd_dev_ktype
  2025-04-27 15:48 [PATCH] block: rnbd: add .release to rnbd_dev_ktype Salah Triki
@ 2025-04-27 22:03 ` Jens Axboe
  2025-04-28  8:24   ` John Garry
  2025-04-28  9:58 ` Jinpu Wang
  1 sibling, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2025-04-27 22:03 UTC (permalink / raw)
  To: Salah Triki, Md. Haris Iqbal, Jack Wang, linux-block,
	linux-kernel

On 4/27/25 9:48 AM, Salah Triki wrote:
> Every ktype must provides a .release function that will be called after
> the last kobject_put.

This commit needs:

1) A description of the problem. There's just a vague statement in
   there.
2) A Fixes tag

-- 
Jens Axboe

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

* Re: [PATCH] block: rnbd: add .release to rnbd_dev_ktype
  2025-04-27 22:03 ` Jens Axboe
@ 2025-04-28  8:24   ` John Garry
  0 siblings, 0 replies; 5+ messages in thread
From: John Garry @ 2025-04-28  8:24 UTC (permalink / raw)
  To: Jens Axboe, Salah Triki, Md. Haris Iqbal, Jack Wang, linux-block,
	linux-kernel

On 27/04/2025 23:03, Jens Axboe wrote:
> On 4/27/25 9:48 AM, Salah Triki wrote:
>> Every ktype must provides a .release function that will be called after
>> the last kobject_put.

You could mention Documentation/core-api/kobject.rst?h=v6.15-rc3#n279, 
which tells us this. As does the check in kobject_cleanup().

> 
> This commit needs:
> 
> 1) A description of the problem. There's just a vague statement in
>     there.
> 2) A Fixes tag
> 




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

* Re: [PATCH] block: rnbd: add .release to rnbd_dev_ktype
  2025-04-27 15:48 [PATCH] block: rnbd: add .release to rnbd_dev_ktype Salah Triki
  2025-04-27 22:03 ` Jens Axboe
@ 2025-04-28  9:58 ` Jinpu Wang
  2025-05-04 17:20   ` Bart Van Assche
  1 sibling, 1 reply; 5+ messages in thread
From: Jinpu Wang @ 2025-04-28  9:58 UTC (permalink / raw)
  To: Salah Triki; +Cc: Md. Haris Iqbal, Jens Axboe, linux-block, linux-kernel

Hi,

On Sun, Apr 27, 2025 at 5:48 PM Salah Triki <salah.triki@gmail.com> wrote:
>
> Every ktype must provides a .release function that will be called after
> the last kobject_put.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
This change cause crashing during unmap device.
We already have rnbd_client_release from rnbd_client_ops, so no memleak.

Nacked.

Thx!
> ---
>  drivers/block/rnbd/rnbd-clt-sysfs.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/drivers/block/rnbd/rnbd-clt-sysfs.c b/drivers/block/rnbd/rnbd-clt-sysfs.c
> index 6ea7c12e3a87..144aea1466a4 100644
> --- a/drivers/block/rnbd/rnbd-clt-sysfs.c
> +++ b/drivers/block/rnbd/rnbd-clt-sysfs.c
> @@ -475,9 +475,17 @@ void rnbd_clt_remove_dev_symlink(struct rnbd_clt_dev *dev)
>         }
>  }
>
> +static void rnbd_dev_release(struct kobject *kobj)
> +{
> +       struct rnbd_clt_dev *dev = container_of(kobj, struct rnbd_clt_dev, kobj);
> +
> +       kfree(dev);
> +}
> +
>  static const struct kobj_type rnbd_dev_ktype = {
>         .sysfs_ops      = &kobj_sysfs_ops,
>         .default_groups = rnbd_dev_groups,
> +       .release        = rnbd_dev_release,
>  };
>
>  static int rnbd_clt_add_dev_kobj(struct rnbd_clt_dev *dev)
> --
> 2.43.0
>

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

* Re: [PATCH] block: rnbd: add .release to rnbd_dev_ktype
  2025-04-28  9:58 ` Jinpu Wang
@ 2025-05-04 17:20   ` Bart Van Assche
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2025-05-04 17:20 UTC (permalink / raw)
  To: Jinpu Wang, Salah Triki
  Cc: Md. Haris Iqbal, Jens Axboe, linux-block, linux-kernel

On 4/28/25 2:58 AM, Jinpu Wang wrote:
> Nacked.

Instead of NAK-ing this patch, please rework the rnbd driver such that
rnbd_dev_ktype has a .release method and the driver keeps working fine.

Bart.

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

end of thread, other threads:[~2025-05-04 17:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-27 15:48 [PATCH] block: rnbd: add .release to rnbd_dev_ktype Salah Triki
2025-04-27 22:03 ` Jens Axboe
2025-04-28  8:24   ` John Garry
2025-04-28  9:58 ` Jinpu Wang
2025-05-04 17:20   ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox