linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] kobject: Drop unneeded conditional in __kobject_del()
@ 2020-08-03  8:35 Andy Shevchenko
  2020-08-03 11:26 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2020-08-03  8:35 UTC (permalink / raw)
  To: Greg Kroah-Hartman, linux-kernel, Rafael J. Wysocki; +Cc: Andy Shevchenko

__kobject_del() is called from two places, in one where kobj is dereferenced
before and thus can't be NULL, and in the other the NULL check is done before
call. Drop unneeded conditional in __kobject_del().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

It is possible after refactoring kobject_del(). Though I decided to do it in
a separate change (no need to backport) for better test coverage.

 lib/kobject.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lib/kobject.c b/lib/kobject.c
index 9dce68c378e6..ea53b30cf483 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -604,9 +604,6 @@ static void __kobject_del(struct kobject *kobj)
 	struct kernfs_node *sd;
 	const struct kobj_type *ktype;
 
-	if (!kobj)
-		return;
-
 	sd = kobj->sd;
 	ktype = get_ktype(kobj);
 
-- 
2.27.0


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

* Re: [PATCH v1] kobject: Drop unneeded conditional in __kobject_del()
  2020-08-03  8:35 [PATCH v1] kobject: Drop unneeded conditional in __kobject_del() Andy Shevchenko
@ 2020-08-03 11:26 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2020-08-03 11:26 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Linux Kernel Mailing List, Rafael J. Wysocki

On Mon, Aug 3, 2020 at 10:35 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> __kobject_del() is called from two places, in one where kobj is dereferenced
> before and thus can't be NULL, and in the other the NULL check is done before
> call. Drop unneeded conditional in __kobject_del().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>
> It is possible after refactoring kobject_del(). Though I decided to do it in
> a separate change (no need to backport) for better test coverage.
>
>  lib/kobject.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/lib/kobject.c b/lib/kobject.c
> index 9dce68c378e6..ea53b30cf483 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -604,9 +604,6 @@ static void __kobject_del(struct kobject *kobj)
>         struct kernfs_node *sd;
>         const struct kobj_type *ktype;
>
> -       if (!kobj)
> -               return;
> -
>         sd = kobj->sd;
>         ktype = get_ktype(kobj);
>
> --
> 2.27.0
>

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

end of thread, other threads:[~2020-08-03 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-03  8:35 [PATCH v1] kobject: Drop unneeded conditional in __kobject_del() Andy Shevchenko
2020-08-03 11:26 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).