lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1550015279-42723-1-git-send-email-wen.yang99@zte.com.cn>
Date:   Wed, 13 Feb 2019 07:47:59 +0800
From:   Wen Yang <wen.yang99@....com.cn>
To:     m.szyprowski@...sung.com
Cc:     mchehab@...nel.org, linux-samsung-soc@...r.kernel.org,
        linux-media@...r.kernel.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>,
        Hans Verkuil <hans.verkuil@...co.com>,
        Wen Yang <yellowriver2010@...mail.com>
Subject: [PATCH v2 3/4] media: s5p-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.
This patch fixes those two issues.

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.

Fixes: a93d429b51fb ("[media] s5p-cec: add cec-notifier support, move out of staging")
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: Hans Verkuil <hans.verkuil@...co.com>
Cc: Marek Szyprowski <m.szyprowski@...sung.com>
Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
Cc: Wen Yang <yellowriver2010@...mail.com>
Cc: linux-samsung-soc@...r.kernel.org
Cc: linux-media@...r.kernel.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/s5p-cec/s5p_cec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/platform/s5p-cec/s5p_cec.c b/drivers/media/platform/s5p-cec/s5p_cec.c
index 8837e26..1f5c355 100644
--- a/drivers/media/platform/s5p-cec/s5p_cec.c
+++ b/drivers/media/platform/s5p-cec/s5p_cec.c
@@ -192,9 +192,11 @@ static int s5p_cec_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 	hdmi_dev = of_find_device_by_node(np);
+	of_node_put(np);
 	if (hdmi_dev == NULL)
 		return -EPROBE_DEFER;
 
+	put_device(&hdmi_dev->dev);
 	cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL);
 	if (!cec)
 		return -ENOMEM;
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ