Linux-Media Archive on lore.kernel.org
 help / Atom feed
* Re: [PATCH 2/4] media: platform: meson-ao-cec: fix possible object reference leak
       [not found] <HK0PR02MB3634925866F426F86DD213BDB26A0@HK0PR02MB3634.apcprd02.prod.outlook.com>
@ 2019-02-10 10:57 ` Neil Armstrong
  0 siblings, 0 replies; 1+ messages in thread
From: Neil Armstrong @ 2019-02-10 10:57 UTC (permalink / raw)
  To: Wen Yang, Mauro Carvalho Chehab, Kevin Hilman
  Cc: linux-media, linux-amlogic, linux-media, linux-arm-kernel, linux-kernel



Le 09/02/2019 03:52, Wen Yang a écrit :
> The call to of_parse_phandle() returns a node pointer with refcount
> incremented thus it must be explicitly decremented here after the last
> usage.
> The of_find_device_by_node() takes a reference to the underlying device
> structure, we also should release that reference.
> This patch fixes those two issues.
> 
> Fixes: 7ec2c0f72cb1 ("media: platform: Add Amlogic Meson AO CEC Controller driver")
> Signed-off-by: Wen Yang <yellowriver2010@hotmail.com>
> ---
>  drivers/media/platform/meson/ao-cec.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/meson/ao-cec.c b/drivers/media/platform/meson/ao-cec.c
> index cd4be38..8ba8b46 100644
> --- a/drivers/media/platform/meson/ao-cec.c
> +++ b/drivers/media/platform/meson/ao-cec.c
> @@ -613,18 +613,25 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
>  	}
>  
>  	hdmi_dev = of_find_device_by_node(np);
> -	if (hdmi_dev == NULL)
> +	if (hdmi_dev == NULL) {
> +		of_node_put(np);
>  		return -EPROBE_DEFER;
> +	}
>  
> +	of_node_put(np);
>  	ao_cec = devm_kzalloc(&pdev->dev, sizeof(*ao_cec), GFP_KERNEL);
> -	if (!ao_cec)
> +	if (!ao_cec) {
> +		put_device(&hdmi_dev->dev);
>  		return -ENOMEM;
> +	}
>  
>  	spin_lock_init(&ao_cec->cec_reg_lock);
>  
>  	ao_cec->notify = cec_notifier_get(&hdmi_dev->dev);
> -	if (!ao_cec->notify)
> +	if (!ao_cec->notify) {
> +		put_device(&hdmi_dev->dev);
>  		return -ENOMEM;
> +	}
>  
>  	ao_cec->adap = cec_allocate_adapter(&meson_ao_cec_ops, ao_cec,
>  					    "meson_ao_cec",
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

Thanks for the fix !

Neil

^ permalink raw reply	[flat|nested] 1+ messages in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <HK0PR02MB3634925866F426F86DD213BDB26A0@HK0PR02MB3634.apcprd02.prod.outlook.com>
2019-02-10 10:57 ` [PATCH 2/4] media: platform: meson-ao-cec: fix possible object reference leak Neil Armstrong

Linux-Media Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-media/0 linux-media/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-media linux-media/ https://lore.kernel.org/linux-media \
		linux-media@vger.kernel.org linux-media@archiver.kernel.org
	public-inbox-index linux-media


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-media


AGPL code for this site: git clone https://public-inbox.org/ public-inbox