diff options
| author | Jakob Koschel <jakobkoschel@gmail.com> | 2022-02-28 15:24:33 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-04-20 09:06:35 +0200 |
| commit | 23d741b4903e2b81270e7c2ed327aa61d1b59304 (patch) | |
| tree | 1d6220362a6047c9b0cc3c3299ca421de6728028 /arch | |
| parent | a6a3ec1626846fba62609330673a2dd5007d6a53 (diff) | |
| download | linux-23d741b4903e2b81270e7c2ed327aa61d1b59304.tar.gz linux-23d741b4903e2b81270e7c2ed327aa61d1b59304.tar.bz2 linux-23d741b4903e2b81270e7c2ed327aa61d1b59304.zip | |
powerpc/sysdev: fix incorrect use to determine if list is empty
[ Upstream commit fa1321b11bd01752f5be2415e74a0e1a7c378262 ]
'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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220228142434.576226-1-jakobkoschel@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/powerpc/sysdev/fsl_gtm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c index a6f0b96ce2c9..97dee7c99aa0 100644 --- a/arch/powerpc/sysdev/fsl_gtm.c +++ b/arch/powerpc/sysdev/fsl_gtm.c @@ -90,7 +90,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, >ms, list_node) { @@ -107,7 +107,7 @@ struct gtm_timer *gtm_get_timer16(void) spin_unlock_irq(>m->lock); } - if (gtm) + if (!list_empty(>ms)) return ERR_PTR(-EBUSY); return ERR_PTR(-ENODEV); } |
