linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Scally <djrscally@gmail.com>
To: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: linuxarm@huawei.com, mauro.chehab@huawei.com,
	Bingbu Cao <bingbu.cao@intel.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: Re: [PATCH] media: ipu3: don't use recursion at the Kernel
Date: Thu, 2 Dec 2021 12:31:47 +0000	[thread overview]
Message-ID: <1a1437f7-89e9-73f5-a197-c2b7c9536846@gmail.com> (raw)
In-Reply-To: <cf020b6a04b3a9d7f08750927b1d100f63ff4689.1638445455.git.mchehab+huawei@kernel.org>

Hi Mauro

On 02/12/2021 11:44, Mauro Carvalho Chehab wrote:
> 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.


TIL - I'll bear that in mind in the future, thanks.

> So, re-implement cio2_check_fwnode_graph() to avoid
> recursion.
>
> Compile-tested only.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>


FWIW:

Reviewed-by: Daniel Scally <djrscally@gmail.com>

Tested-by: Daniel Scally <djrscally@gmail.com>

> ---
>  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 ****************/

  reply	other threads:[~2021-12-02 12:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 11:44 [PATCH] media: ipu3: don't use recursion at the Kernel Mauro Carvalho Chehab
2021-12-02 12:31 ` Daniel Scally [this message]
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=1a1437f7-89e9-73f5-a197-c2b7c9536846@gmail.com \
    --to=djrscally@gmail.com \
    --cc=bingbu.cao@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mauro.chehab@huawei.com \
    --cc=mchehab+huawei@kernel.org \
    --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).