You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
powerpc/sysdev: fix incorrect use to determine if list is empty
[ Upstream commitfa1321b11b] '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:83ff9dcf37("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ab0a335b54
commit
bcf93175ed
@@ -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, >ms, list_node) {
|
||||
@@ -103,7 +103,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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user