All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: ohad@wizery.com, s-anna@ti.com, elder@linaro.org,
	Markus.Elfring@web.de, linux-remoteproc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/7] remoteproc: Fix IDR initialisation in rproc_alloc()
Date: Sun, 19 Apr 2020 22:00:54 -0700	[thread overview]
Message-ID: <20200420050051.GB1516868@builder.lan> (raw)
In-Reply-To: <20200415204858.2448-2-mathieu.poirier@linaro.org>

On Wed 15 Apr 13:48 PDT 2020, Mathieu Poirier wrote:

> From: Alex Elder <elder@linaro.org>
> 
> If ida_simple_get() returns an error when called in rproc_alloc(),
> put_device() is called to clean things up.  By this time the rproc
> device type has been assigned, with rproc_type_release() as the
> release function.
> 
> The first thing rproc_type_release() does is call:
>     idr_destroy(&rproc->notifyids);
> 
> But at the time the ida_simple_get() call is made, the notifyids
> field in the remoteproc structure has not been initialized.
> 
> I'm not actually sure this case causes an observable problem, but
> it's incorrect.  Fix this by initializing the notifyids field before
> calling ida_simple_get() in rproc_alloc().
> 
> Fixes: b5ab5e24e960 ("remoteproc: maintain a generic child device for each rproc")
> Signed-off-by: Alex Elder <elder@linaro.org>
> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  drivers/remoteproc/remoteproc_core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index e12a54e67588..80056513ae71 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2053,6 +2053,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
>  	rproc->dev.type = &rproc_type;
>  	rproc->dev.class = &rproc_class;
>  	rproc->dev.driver_data = rproc;
> +	idr_init(&rproc->notifyids);
>  
>  	/* Assign a unique device index and name */
>  	rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
> @@ -2078,8 +2079,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
>  
>  	mutex_init(&rproc->lock);
>  
> -	idr_init(&rproc->notifyids);
> -
>  	INIT_LIST_HEAD(&rproc->carveouts);
>  	INIT_LIST_HEAD(&rproc->mappings);
>  	INIT_LIST_HEAD(&rproc->traces);
> -- 
> 2.20.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: ohad@wizery.com, s-anna@ti.com, elder@linaro.org,
	Markus.Elfring@web.de, linux-remoteproc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/7] remoteproc: Fix IDR initialisation in rproc_alloc()
Date: Sun, 19 Apr 2020 22:00:51 -0700	[thread overview]
Message-ID: <20200420050051.GB1516868@builder.lan> (raw)
Message-ID: <20200420050051.KUGKB6o6ysCAaJwqBJuIe1i83RjnIher8FNj38GHr3M@z> (raw)
In-Reply-To: <20200415204858.2448-2-mathieu.poirier@linaro.org>

On Wed 15 Apr 13:48 PDT 2020, Mathieu Poirier wrote:

> From: Alex Elder <elder@linaro.org>
> 
> If ida_simple_get() returns an error when called in rproc_alloc(),
> put_device() is called to clean things up.  By this time the rproc
> device type has been assigned, with rproc_type_release() as the
> release function.
> 
> The first thing rproc_type_release() does is call:
>     idr_destroy(&rproc->notifyids);
> 
> But at the time the ida_simple_get() call is made, the notifyids
> field in the remoteproc structure has not been initialized.
> 
> I'm not actually sure this case causes an observable problem, but
> it's incorrect.  Fix this by initializing the notifyids field before
> calling ida_simple_get() in rproc_alloc().
> 
> Fixes: b5ab5e24e960 ("remoteproc: maintain a generic child device for each rproc")
> Signed-off-by: Alex Elder <elder@linaro.org>
> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---
>  drivers/remoteproc/remoteproc_core.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index e12a54e67588..80056513ae71 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -2053,6 +2053,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
>  	rproc->dev.type = &rproc_type;
>  	rproc->dev.class = &rproc_class;
>  	rproc->dev.driver_data = rproc;
> +	idr_init(&rproc->notifyids);
>  
>  	/* Assign a unique device index and name */
>  	rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
> @@ -2078,8 +2079,6 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
>  
>  	mutex_init(&rproc->lock);
>  
> -	idr_init(&rproc->notifyids);
> -
>  	INIT_LIST_HEAD(&rproc->carveouts);
>  	INIT_LIST_HEAD(&rproc->mappings);
>  	INIT_LIST_HEAD(&rproc->traces);
> -- 
> 2.20.1
> 

  parent reply	other threads:[~2020-04-20  5:00 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15 20:48 [PATCH v2 0/7] remoteproc: Refactor function rproc_alloc() Mathieu Poirier
2020-04-15 20:48 ` [PATCH v2 1/7] remoteproc: Fix IDR initialisation in rproc_alloc() Mathieu Poirier
2020-04-17 13:37   ` Suman Anna
2020-04-17 13:37     ` Suman Anna
2020-04-20  5:00   ` Bjorn Andersson [this message]
2020-04-20  5:00     ` Bjorn Andersson
2020-04-20  5:00       ` Bjorn Andersson
2020-04-15 20:48 ` [PATCH v2 2/7] remoteproc: Split firmware name allocation from rproc_alloc() Mathieu Poirier
2020-04-15 21:28   ` Alex Elder
2020-04-20  5:09   ` Bjorn Andersson
2020-04-20  5:09     ` Bjorn Andersson
2020-04-20  5:09       ` Bjorn Andersson
2020-04-20  9:24   ` Arnaud POULIQUEN
2020-04-20  9:24     ` Arnaud POULIQUEN
2020-04-20 21:29     ` Mathieu Poirier
2020-04-15 20:48 ` [PATCH v2 3/7] remoteproc: Simplify default name allocation Mathieu Poirier
2020-04-15 21:26   ` Alex Elder
2020-04-20  5:10   ` Bjorn Andersson
2020-04-20  5:10     ` Bjorn Andersson
2020-04-20  5:10       ` Bjorn Andersson
2020-04-15 20:48 ` [PATCH v2 4/7] remoteproc: Use kstrdup_const() rather than kstrup() Mathieu Poirier
2020-04-15 21:25   ` Alex Elder
2020-04-17 13:44     ` Suman Anna
2020-04-17 13:44       ` Suman Anna
2020-04-20  5:21       ` Bjorn Andersson
2020-04-20  5:21         ` Bjorn Andersson
2020-04-20  5:21           ` Bjorn Andersson
2020-04-17 16:12   ` [v2 4/7] remoteproc: Use kstrdup_const() rather than kstrdup() Markus Elfring
2020-04-15 20:48 ` [PATCH v2 5/7] remoteproc: Restructure firmware name allocation Mathieu Poirier
2020-04-15 21:23   ` Alex Elder
2020-04-20  5:17     ` Bjorn Andersson
2020-04-20  5:17       ` Bjorn Andersson
2020-04-20  5:17         ` Bjorn Andersson
2020-04-16  6:26   ` Markus Elfring
2020-04-17 13:39     ` Suman Anna
2020-04-17 13:39       ` Suman Anna
2020-04-17 15:48       ` [v2 " Markus Elfring
2020-04-17 16:15         ` Suman Anna
2020-04-17 16:15           ` Suman Anna
2020-04-17 20:58         ` Mathieu Poirier
2020-04-17 21:28       ` [PATCH v2 " Mathieu Poirier
2020-04-15 20:48 ` [PATCH v2 6/7] remoteproc: Split rproc_ops allocation from rproc_alloc() Mathieu Poirier
2020-04-17 13:49   ` Suman Anna
2020-04-17 13:49     ` Suman Anna
2020-04-17 15:35     ` Suman Anna
2020-04-17 15:35       ` Suman Anna
2020-04-17 21:56     ` Mathieu Poirier
2020-04-15 20:48 ` [PATCH v2 7/7] remoteproc: Get rid of tedious error path Mathieu Poirier
2020-04-17 13:50   ` Suman Anna
2020-04-17 13:50     ` Suman Anna
2020-04-17 13:34 ` [PATCH v2 0/7] remoteproc: Refactor function rproc_alloc() Suman Anna
2020-04-17 13:34   ` Suman Anna

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=20200420050051.GB1516868@builder.lan \
    --to=bjorn.andersson@linaro.org \
    --cc=Markus.Elfring@web.de \
    --cc=elder@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=ohad@wizery.com \
    --cc=s-anna@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.