All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/sysdev: fix incorrect use to determine if list is empty
@ 2022-02-28 14:24 ` Jakob Koschel
  0 siblings, 0 replies; 4+ messages in thread
From: Jakob Koschel @ 2022-02-28 14:24 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Jakob Koschel, Benjamin Herrenschmidt, Paul Mackerras,
	Anton Vorontsov, Kumar Gala, linuxppc-dev, linux-kernel

'gtm' will *always* be set by list_for_each_entry().
It is incorrect to assume that the iterator value will be NULL if the
list is empty.

Instead of checking the pointer it should be checked if
the list is empty.

Fixes: 83ff9dcf375c ("powerpc/sysdev: implement FSL GTM support")
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 arch/powerpc/sysdev/fsl_gtm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c
index 8963eaffb1b7..39186ad6b3c3 100644
--- a/arch/powerpc/sysdev/fsl_gtm.c
+++ b/arch/powerpc/sysdev/fsl_gtm.c
@@ -86,7 +86,7 @@ static LIST_HEAD(gtms);
  */
 struct gtm_timer *gtm_get_timer16(void)
 {
-	struct gtm *gtm = NULL;
+	struct gtm *gtm;
 	int i;

 	list_for_each_entry(gtm, &gtms, list_node) {
@@ -103,7 +103,7 @@ struct gtm_timer *gtm_get_timer16(void)
 		spin_unlock_irq(&gtm->lock);
 	}

-	if (gtm)
+	if (!list_empty(&gtms))
 		return ERR_PTR(-EBUSY);
 	return ERR_PTR(-ENODEV);
 }

base-commit: 7ee022567bf9e2e0b3cd92461a2f4986ecc99673
--
2.25.1


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

* [PATCH] powerpc/sysdev: fix incorrect use to determine if list is empty
@ 2022-02-28 14:24 ` Jakob Koschel
  0 siblings, 0 replies; 4+ messages in thread
From: Jakob Koschel @ 2022-02-28 14:24 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Kumar Gala, linux-kernel, Paul Mackerras, Jakob Koschel,
	Anton Vorontsov, linuxppc-dev

'gtm' will *always* be set by list_for_each_entry().
It is incorrect to assume that the iterator value will be NULL if the
list is empty.

Instead of checking the pointer it should be checked if
the list is empty.

Fixes: 83ff9dcf375c ("powerpc/sysdev: implement FSL GTM support")
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
---
 arch/powerpc/sysdev/fsl_gtm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c
index 8963eaffb1b7..39186ad6b3c3 100644
--- a/arch/powerpc/sysdev/fsl_gtm.c
+++ b/arch/powerpc/sysdev/fsl_gtm.c
@@ -86,7 +86,7 @@ static LIST_HEAD(gtms);
  */
 struct gtm_timer *gtm_get_timer16(void)
 {
-	struct gtm *gtm = NULL;
+	struct gtm *gtm;
 	int i;

 	list_for_each_entry(gtm, &gtms, list_node) {
@@ -103,7 +103,7 @@ struct gtm_timer *gtm_get_timer16(void)
 		spin_unlock_irq(&gtm->lock);
 	}

-	if (gtm)
+	if (!list_empty(&gtms))
 		return ERR_PTR(-EBUSY);
 	return ERR_PTR(-ENODEV);
 }

base-commit: 7ee022567bf9e2e0b3cd92461a2f4986ecc99673
--
2.25.1


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

* Re: [PATCH] powerpc/sysdev: fix incorrect use to determine if list is empty
  2022-02-28 14:24 ` Jakob Koschel
@ 2022-03-08 12:07   ` Michael Ellerman
  -1 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2022-03-08 12:07 UTC (permalink / raw)
  To: Jakob Koschel, Michael Ellerman
  Cc: linuxppc-dev, Paul Mackerras, linux-kernel,
	Benjamin Herrenschmidt, Kumar Gala

On Mon, 28 Feb 2022 15:24:33 +0100, Jakob Koschel wrote:
> 'gtm' will *always* be set by list_for_each_entry().
> It is incorrect to assume that the iterator value will be NULL if the
> list is empty.
> 
> Instead of checking the pointer it should be checked if
> the list is empty.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/sysdev: fix incorrect use to determine if list is empty
      https://git.kernel.org/powerpc/c/fa1321b11bd01752f5be2415e74a0e1a7c378262

cheers

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

* Re: [PATCH] powerpc/sysdev: fix incorrect use to determine if list is empty
@ 2022-03-08 12:07   ` Michael Ellerman
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2022-03-08 12:07 UTC (permalink / raw)
  To: Jakob Koschel, Michael Ellerman
  Cc: Paul Mackerras, linuxppc-dev, linux-kernel, Kumar Gala

On Mon, 28 Feb 2022 15:24:33 +0100, Jakob Koschel wrote:
> 'gtm' will *always* be set by list_for_each_entry().
> It is incorrect to assume that the iterator value will be NULL if the
> list is empty.
> 
> Instead of checking the pointer it should be checked if
> the list is empty.
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc/sysdev: fix incorrect use to determine if list is empty
      https://git.kernel.org/powerpc/c/fa1321b11bd01752f5be2415e74a0e1a7c378262

cheers

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

end of thread, other threads:[~2022-03-08 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 14:24 [PATCH] powerpc/sysdev: fix incorrect use to determine if list is empty Jakob Koschel
2022-02-28 14:24 ` Jakob Koschel
2022-03-08 12:07 ` Michael Ellerman
2022-03-08 12:07   ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.