Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4527797imj; Tue, 12 Feb 2019 18:35:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IbNUdjxJkRnYlcSo/WH9TGSn3m5D9fhxk080PEl8ZCVWFWH+Am8eKh/6tqVxPSOmwWcNivn X-Received: by 2002:aa7:81c5:: with SMTP id c5mr3791741pfn.217.1550025346007; Tue, 12 Feb 2019 18:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550025346; cv=none; d=google.com; s=arc-20160816; b=JGvbL/EnJwb7ABvCX7XqBFjNBniPuHK9lQnXVNUhj6op6JOle+aen/PivK5sU9cJH/ Ecb2BfeJpFkS7Q+Qj2wkPbHaZHhQwkZdrUwvc4P8c2fxR2k2h/FatDeFb8k/K92fRz/t UkN7fRWkQGEPdvX3Xf1Dc+DRQm/YISl/aaogpztd9vAcqgGWnM6yhWN8Fey6zMgb2rkg v0QP7va1kjU/fAJx/YbfZcLxQ3Jq192POkSWDMX0w5pMrHAGTYY1ku0z5xIpKK4tv8fn byCE45VLbghiaS1xrnY/ix0rvTZhYz2bKb1zox9wFE9Thf1XOFtsFJJligd3OreI5XD5 seaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=6//m2jGWpT+6ZrQTZe66HFKMmSgFSMBHB/7RuNwkNE8=; b=TSqF4OqHDBZgcDikQArUnhBeOwtdcYAgFJ0vdjeITaHUy42D2i4Co9DxYnZXZr0HiU 3Px7ilIxz8F6PNKCWrSUAc64T6tZdMnLNQspxW5pXuvyWt7sjZZdm4jMOkfyDKW2HDna Bsyi1Uig07LMcBHTLsZPqYsTvgzdhZ5YfRtPQRQVnbAXWmfVEzCTC7xNtUA+9UM65Vd3 yWZl5NTWFgvFJhs6rK1RauA5qkw2RPSfRL05Z+Q/7JCap0apDTwoXmSWWF2QBC810R7K nAM9EYJimWzRuVGbsFYPTV+jPRYUyF+4Hns4Qu0Nisedg3PYgdazFdUS1M2dj4bfVb1q mEvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w15si6649640plk.357.2019.02.12.18.35.30; Tue, 12 Feb 2019 18:35:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732278AbfBLXt7 (ORCPT + 99 others); Tue, 12 Feb 2019 18:49:59 -0500 Received: from mxhk.zte.com.cn ([63.217.80.70]:54484 "EHLO mxhk.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728445AbfBLXt7 (ORCPT ); Tue, 12 Feb 2019 18:49:59 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 9DD0DDBCF2CD546476AA; Wed, 13 Feb 2019 07:49:56 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x1CNnpY5002336; Wed, 13 Feb 2019 07:49:51 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019021307501023-25782424 ; Wed, 13 Feb 2019 07:50:10 +0800 From: Wen Yang To: benjamin.gaignard@linaro.org Cc: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn, Wen Yang , "Hans Verkuil (hansverk)" , Wen Yang Subject: [PATCH v2 4/4] media: platform: sti: fix possible object reference leak Date: Wed, 13 Feb 2019 07:48:49 +0800 Message-Id: <1550015329-42952-1-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-02-13 07:50:10, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-02-13 07:49:44, Serialize complete at 2019-02-13 07:49:44 X-MAIL: mse01.zte.com.cn x1CNnpY5002336 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: fc4e009c6c98 ("[media] stih-cec: add CEC notifier support") Suggested-by: Hans Verkuil (hansverk) Signed-off-by: Wen Yang Cc: Hans Verkuil (hansverk) Cc: Benjamin Gaignard Cc: Mauro Carvalho Chehab Cc: Wen Yang Cc: linux-media@vger.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/sti/cec/stih-cec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/sti/cec/stih-cec.c b/drivers/media/platform/sti/cec/stih-cec.c index d34099f..721021f 100644 --- a/drivers/media/platform/sti/cec/stih-cec.c +++ b/drivers/media/platform/sti/cec/stih-cec.c @@ -317,9 +317,11 @@ static int stih_cec_probe(struct platform_device *pdev) } hdmi_dev = of_find_device_by_node(np); + of_node_put(np); if (!hdmi_dev) return -EPROBE_DEFER; + put_device(&hdmi_dev->dev); cec->notifier = cec_notifier_get(&hdmi_dev->dev); if (!cec->notifier) return -ENOMEM; -- 2.9.5