From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linuxarm@huawei.com, mauro.chehab@huawei.com,
Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
Bingbu Cao <bingbu.cao@intel.com>,
Dan Scally <djrscally@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Tianshu Qiu <tian.shu.qiu@intel.com>,
Yong Zhi <yong.zhi@intel.com>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org
Subject: [PATCH] media: ipu3: don't use recursion at the Kernel
Date: Thu, 2 Dec 2021 12:44:26 +0100 [thread overview]
Message-ID: <cf020b6a04b3a9d7f08750927b1d100f63ff4689.1638445455.git.mchehab+huawei@kernel.org> (raw)
The Kernel stack is too small. Doing recursions there is a very
bad idea, as, if something gets wrong, it could lead to data
corruption. So, re-implement cio2_check_fwnode_graph() to avoid
recursion.
Compile-tested only.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index 356ea966cf8d..8e4f250a8b56 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -1691,16 +1691,15 @@ static int cio2_check_fwnode_graph(struct fwnode_handle *fwnode)
{
struct fwnode_handle *endpoint;
- if (IS_ERR_OR_NULL(fwnode))
- return -EINVAL;
-
- endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
- if (endpoint) {
- fwnode_handle_put(endpoint);
- return 0;
+ while (!IS_ERR_OR_NULL(fwnode)) {
+ endpoint = fwnode_graph_get_next_endpoint(fwnode, NULL);
+ if (endpoint) {
+ fwnode_handle_put(endpoint);
+ return 0;
+ }
+ fwnode = fwnode->secondary;
}
-
- return cio2_check_fwnode_graph(fwnode->secondary);
+ return -EINVAL;
}
/**************** PCI interface ****************/
--
2.33.1
next reply other threads:[~2021-12-02 11:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 11:44 Mauro Carvalho Chehab [this message]
2021-12-02 12:31 ` [PATCH] media: ipu3: don't use recursion at the Kernel Daniel Scally
2021-12-02 12:50 ` Sakari Ailus
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=cf020b6a04b3a9d7f08750927b1d100f63ff4689.1638445455.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=bingbu.cao@intel.com \
--cc=djrscally@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mauro.chehab@huawei.com \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=tian.shu.qiu@intel.com \
--cc=yong.zhi@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).