[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1550015075-41548-1-git-send-email-wen.yang99@zte.com.cn>
Date: Wed, 13 Feb 2019 07:44:35 +0800
From: Wen Yang <wen.yang99@....com.cn>
To: narmstrong@...libre.com
Cc: mchehab@...nel.org, khilman@...libre.com,
linux-media@...ts.freedesktop.org,
linux-amlogic@...ts.infradead.org, linux-media@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
xue.zhihong@....com.cn, wang.yi59@....com.cn,
Wen Yang <wen.yang99@....com.cn>,
"Hans Verkuil (hansverk)" <hansverk@...co.com>,
Wen Yang <yellowriver2010@...mail.com>
Subject: [PATCH v2 1/4] media: platform: meson-ao-cec: fix possible object reference leak
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.
Hans Verkuil says:
The cec driver should never take a reference of the hdmi device.
It never accesses the HDMI device, it only needs the HDMI device pointer as
a key in the notifier list.
The real problem is that several CEC drivers take a reference of the HDMI
device and never release it. So those drivers need to be fixed.
This patch fixes those two issues.
Fixes: 7ec2c0f72cb1 ("media: platform: Add Amlogic Meson AO CEC Controller driver")
Suggested-by: Hans Verkuil (hansverk) <hansverk@...co.com>
Signed-off-by: Wen Yang <wen.yang99@....com.cn>
Cc: Hans Verkuil (hansverk) <hansverk@...co.com>
Cc: Neil Armstrong <narmstrong@...libre.com>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: Kevin Hilman <khilman@...libre.com>
Cc: Wen Yang <yellowriver2010@...mail.com>
Cc: linux-media@...ts.freedesktop.org
Cc: linux-amlogic@...ts.infradead.org
Cc: linux-media@...r.kernel.org
Cc: linux-arm-kernel@...ts.infradead.org
---
v2->v1:
- move of_node_put() to just after the 'hdmi_dev = of_find_device_by_node(np)'.
- put_device() can be done before the cec = devm_kzalloc line.
drivers/media/platform/meson/ao-cec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/platform/meson/ao-cec.c b/drivers/media/platform/meson/ao-cec.c
index cd4be38..f757ece 100644
--- a/drivers/media/platform/meson/ao-cec.c
+++ b/drivers/media/platform/meson/ao-cec.c
@@ -613,9 +613,11 @@ static int meson_ao_cec_probe(struct platform_device *pdev)
}
hdmi_dev = of_find_device_by_node(np);
+ of_node_put(np);
if (hdmi_dev == NULL)
return -EPROBE_DEFER;
+ put_device(&hdmi_dev->dev);
ao_cec = devm_kzalloc(&pdev->dev, sizeof(*ao_cec), GFP_KERNEL);
if (!ao_cec)
return -ENOMEM;
--
2.9.5
Powered by blists - more mailing lists