From: Jakob Koschel <jkl820.git@gmail.com>
To: Vinod Koul <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
Pietro Borrello <borrello@diag.uniroma1.it>,
Cristiano Giuffrida <c.giuffrida@vu.nl>,
"Bos, H.J." <h.j.bos@vu.nl>, Jakob Koschel <jkl820.git@gmail.com>
Subject: [PATCH] dmaengine: ppc4xx: Avoid returning iterator in ppc440spe_get_group_entry()
Date: Wed, 01 Mar 2023 18:28:06 +0100 [thread overview]
Message-ID: <20230301-dmaengine-ppc4xx-avoid-iter-after-loop-v1-1-330689e1e6fd@gmail.com> (raw)
Linus proposed to avoid any use of the list iterator variable after the
loop, in the attempt to move the list iterator variable declaration into
the marcro to avoid any potential misuse after the loop [1].
Instead we'll just return 'iter' within the iterator and otherwise NULL.
This ensures there is never a bogus pointer returned (e.g. if the list
is empty).
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
Signed-off-by: Jakob Koschel <jkl820.git@gmail.com>
---
drivers/dma/ppc4xx/adma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 686c270ef710..f62f9653196f 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -1431,9 +1431,9 @@ ppc440spe_get_group_entry(struct ppc440spe_adma_desc_slot *tdesc, u32 entry_idx)
list_for_each_entry(iter, &tdesc->group_list, chain_node) {
if (i++ == entry_idx)
- break;
+ return iter;
}
- return iter;
+ return NULL;
}
/**
---
base-commit: c0927a7a5391f7d8e593e5e50ead7505a23cadf9
change-id: 20230301-dmaengine-ppc4xx-avoid-iter-after-loop-2860b2b6af41
Best regards,
--
Jakob Koschel <jkl820.git@gmail.com>
reply other threads:[~2023-03-01 17:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230301-dmaengine-ppc4xx-avoid-iter-after-loop-v1-1-330689e1e6fd@gmail.com \
--to=jkl820.git@gmail.com \
--cc=borrello@diag.uniroma1.it \
--cc=c.giuffrida@vu.nl \
--cc=dmaengine@vger.kernel.org \
--cc=h.j.bos@vu.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@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
all inboxes | Powered by JetHome®