The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
Cc: dakr@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/base: fix iterator cleanup in attribute_container
Date: Wed, 26 Feb 2025 11:16:21 -0800	[thread overview]
Message-ID: <2025022606-carrousel-unstable-f2f3@gregkh> (raw)
In-Reply-To: <20250226182753.257559-1-ayaanmirzabaig85@gmail.com>

On Wed, Feb 26, 2025 at 11:57:52PM +0530, Ayaan Mirza Baig wrote:
> This patch addresses a long-standing FIXME in
> dirvers/base/attribute_container.c, where the function
> failed to call klist_iter_exit() before breaking
> out of the loop when a matching class device was found.
> 
> The code is now refactored to use a goto-based cleanup approach
> that ensure klist_iter_exit() is invoked exactly once regardless
> of the exit path.
> 
> In addition, checkpatch.pl warnings were fixed along with this change.
> 
> Tested on a minimal Debian System in QEMU with GDB attached.
> No regressions or errors were observed.
> 
> Signed-off-by: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
> ---
>  drivers/base/attribute_container.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
> index b6f941a6ab69..1e7af328dd49 100644
> --- a/drivers/base/attribute_container.c
> +++ b/drivers/base/attribute_container.c
> @@ -5,7 +5,7 @@
>   * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
>   *
>   * The basic idea here is to enable a device to be attached to an
> - * aritrary numer of classes without having to allocate storage for them.
> + * aritrary number of classes without having to allocate storage for them.

Nit, why change this in this commit?

>   * Instead, the contained classes select the devices they need to attach
>   * to via a matching function.
>   */
> @@ -21,7 +21,8 @@
>  #include "base.h"
>  
>  /* This is a private structure used to tie the classdev and the
> - * container .. it should never be visible outside this file */
> + * container .. it should never be visible outside this file
> + */

Same for this one?
>  struct internal_container {
>  	struct klist_node node;
>  	struct attribute_container *cont;
> @@ -42,7 +43,6 @@ static void internal_container_klist_put(struct klist_node *n)
>  	put_device(&ic->classdev);
>  }
>  
> -
>  /**

And this?

I stopped reading here, please, if you are going to make logic changes,
just do that, don't mix things up in one larger commit, that's not how
we handle kernel patches at all.

Also, did you test a system that uses container devices?

thanks,

greg k-h

  reply	other threads:[~2025-02-26 19:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26 18:27 [PATCH] drivers/base: fix iterator cleanup in attribute_container Ayaan Mirza Baig
2025-02-26 19:16 ` Greg KH [this message]
2025-02-27 12:41   ` [PATCH 1/2] drivers/base: fix checkpatch.pl warnings in attribute_container.c (v2) Ayaan Mirza Baig
2025-03-01  7:31     ` Greg KH
2025-02-27 12:41   ` [PATCH 2/2] drivers/base: fix iterator cleanup in attribute_container_find_class_device (v2) Ayaan Mirza Baig
2025-03-01  7:34     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025022606-carrousel-unstable-f2f3@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=ayaanmirzabaig85@gmail.com \
    --cc=dakr@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox