public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Nicolas Boichat <drinkcat@chromium.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	Pi-Hsun Shih <pihsun@chromium.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH v2] rpmsg: Avoid double-free in mtk_rpmsg_register_device
Date: Wed, 2 Sep 2020 10:55:05 -0600	[thread overview]
Message-ID: <20200902165505.GA280378@xps15> (raw)
In-Reply-To: <20200902190709.v2.1.I56cf27cd59f4013bd074dc622c8b8248b034a4cc@changeid>

On Wed, Sep 02, 2020 at 07:07:15PM +0800, Nicolas Boichat wrote:
> If rpmsg_register_device fails, it will call
> mtk_rpmsg_release_device which already frees mdev.
> 
> Fixes: 7017996951fde84 ("rpmsg: add rpmsg support for mt8183 SCP.")

The SHA should be 12 characters instead of 15.  With that:

Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>

> Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
> ---
> 
> Changes in v2:
>  - Drop useless if and ret variable (Markus Elfring)
> 
>  drivers/rpmsg/mtk_rpmsg.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)
> 
> diff --git a/drivers/rpmsg/mtk_rpmsg.c b/drivers/rpmsg/mtk_rpmsg.c
> index 83f2b8804ee989d..96a17ec2914011d 100644
> --- a/drivers/rpmsg/mtk_rpmsg.c
> +++ b/drivers/rpmsg/mtk_rpmsg.c
> @@ -200,7 +200,6 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
>  	struct rpmsg_device *rpdev;
>  	struct mtk_rpmsg_device *mdev;
>  	struct platform_device *pdev = mtk_subdev->pdev;
> -	int ret;
>  
>  	mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
>  	if (!mdev)
> @@ -219,13 +218,7 @@ static int mtk_rpmsg_register_device(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
>  	rpdev->dev.parent = &pdev->dev;
>  	rpdev->dev.release = mtk_rpmsg_release_device;
>  
> -	ret = rpmsg_register_device(rpdev);
> -	if (ret) {
> -		kfree(mdev);
> -		return ret;
> -	}
> -
> -	return 0;
> +	return rpmsg_register_device(rpdev);
>  }
>  
>  static void mtk_register_device_work_function(struct work_struct *register_work)
> -- 
> 2.28.0.402.g5ffc5be6b7-goog
> 

  reply	other threads:[~2020-09-02 16:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02 11:07 [PATCH v2] rpmsg: Avoid double-free in mtk_rpmsg_register_device Nicolas Boichat
2020-09-02 16:55 ` Mathieu Poirier [this message]
2020-09-03  0:08   ` Nicolas Boichat

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=20200902165505.GA280378@xps15 \
    --to=mathieu.poirier@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=drinkcat@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=ohad@wizery.com \
    --cc=pihsun@chromium.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