Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp105195imj; Wed, 13 Feb 2019 05:29:29 -0800 (PST) X-Google-Smtp-Source: AHgI3IabXjRs4ViopJdOfYjfEtOuBi52M51069+P+ITZKOvII5IGYt+3iUD3wRW8iCKzl+1Ijk0R X-Received: by 2002:a62:2702:: with SMTP id n2mr535869pfn.29.1550064569702; Wed, 13 Feb 2019 05:29:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550064569; cv=none; d=google.com; s=arc-20160816; b=OhW3S6P3d4x8Zk2xzu2FS1qp/TP1ZOgA9xkQTJ97hps9usrqg6VoGvsPgTG15R/xey 926OuZ4LaekJrvW+pk1oieeWuixzGlwkAy5tgFS765VJ2KiAKd+i7JsNIGfejdDj3LUH h962rKMqvU3f5xN2caY10rNxnXYsI6aQABU9+rNtNVJZs0j096WJr1ELbMxlcg7qcJIb tinOSHJlcz5FTcP0ALyXQVQCxWwdBiIE1W/m5+KSUFHn3i2r2TD0cUhsV9j75PEaSuge SkOz8L65MDjvkmy5YwCmmOsLB2HD9AC71mOb6IoeyVmyjCzKM9WwEmygW6xIzpg1+fh6 qtpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=I1X3Rft3KAaL6MPgCKOELxmUZayJ8j4THzbxZjOD2UM=; b=hCemRZtMLvpvPuPsOIviDF/HZsDUk/tm2Q8hfBR5pF0w3qZSX9ljAYAgm5abSIo6vb Fmnz1bJl7K/N5FLCcIJg7xOBCPyJKyXiDm9+2pV5QOCBEskpWgqNgMBp0GGFBaZVgyKN uG4rYg4CayegzD+/3NewYTuztmEodWFv7TjTzHJt8guZjHJnMr7btm/mGp/x9/HHK5kc H5CMZsjZ7oC4mtd5ZK76EGVO5uBG1aQ8cnLxkQICR6Ae789xWkxT5UOJq1KjPyVofLXB dW5Tf1m+giWHvVnuCiaJ++1TRPYzhkKJUZXCUpXKJQaEsgC9VGa+r3juyexPVvs0PB+F SINg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nosDYNW9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h67si11480759pfb.146.2019.02.13.05.28.59; Wed, 13 Feb 2019 05:29:29 -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; dkim=pass header.i=@linaro.org header.s=google header.b=nosDYNW9; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391240AbfBMJHu (ORCPT + 99 others); Wed, 13 Feb 2019 04:07:50 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:42974 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391222AbfBMJHu (ORCPT ); Wed, 13 Feb 2019 04:07:50 -0500 Received: by mail-ot1-f68.google.com with SMTP id i5so2686605oto.9 for ; Wed, 13 Feb 2019 01:07:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=I1X3Rft3KAaL6MPgCKOELxmUZayJ8j4THzbxZjOD2UM=; b=nosDYNW9zG7/FRJyx8MTNfgZ66wKKeA8oALdkIVQvr79dUyfVUjWki5d8yyXJznxBR Jea9jRlUndV3Gppj7FAIEYKuDh6K43UQUP8LcdpAJ03a4i9k7OHsfbMZJYPftNQMTMSd RizR+TFw+nE3bLqRX0D1pzg6aF82McVAcBR4j5CpnfDQ/NqmHmyJLf0xU2JsLPvhjSXu Ms94fdz6G32RG0U4SSG2JV2nVVRi49B+vp65bjue+LSrxUYIdLlx5k6sd1QqsULcqkHX 0WMytVTAuhzRxmQ/2xMXA0NhiVXvHcbsnjHkmVS29XzaxZJj0nabS82CBhXhqGTAfpbk nUPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=I1X3Rft3KAaL6MPgCKOELxmUZayJ8j4THzbxZjOD2UM=; b=JvM2uGSuIZSiekiPpwjgkwDrEEnGgHO4fHcfoxnxD8jGICoLTcACLV6bQNyM/IGN4Q dpiPU50IRWpBB5wZNgWwjfRAS59SqE6Pln5DZKf4xYvf2PGyETl/tZmsgpDNvz6c8YsU xWh3nOBkoy7InrsZqlR+W45F/hcjXRJtQnjSvGZhLx8KQ36x3AKhJwEb8zKE1Xh9ovDR 8XoK8XQiD3seoICzTbPDxW+xsh0HiZ6D8+tpt6WaLDfWcUoqFVPWilYUrh3fJfb97Rax Rf1QRBYXrnIVPgHtzr1oDr0ZunnRUd2x1+6EI2895lnZIrjKDHXsiw10CdhcUT7ynQUa izQw== X-Gm-Message-State: AHQUAuZF62ftdRwNSpXMyoWG1DRpLrtdGld53BrlJZYOZVXLAycSipcH GbxsIM2Q4Lv1ONIzHo3vFdOeK8Jv6ak2hATgobobJg== X-Received: by 2002:aca:cd0e:: with SMTP id d14mr573941oig.11.1550048869246; Wed, 13 Feb 2019 01:07:49 -0800 (PST) MIME-Version: 1.0 References: <1550015329-42952-1-git-send-email-wen.yang99@zte.com.cn> In-Reply-To: <1550015329-42952-1-git-send-email-wen.yang99@zte.com.cn> From: Benjamin Gaignard Date: Wed, 13 Feb 2019 10:07:38 +0100 Message-ID: Subject: Re: [PATCH v2 4/4] media: platform: sti: fix possible object reference leak To: Wen Yang Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, Linux Kernel Mailing List , xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn, "Hans Verkuil (hansverk)" , Wen Yang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le mer. 13 f=C3=A9vr. 2019 =C3=A0 00:49, Wen Yang a= =C3=A9crit : > > 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. Reviewed-by: Benjamin Gaignard > > 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 =3D of_find_device_by_no= de(np)'. > - put_device() can be done before the cec =3D 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/pl= atform/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 *pd= ev) > } > > hdmi_dev =3D of_find_device_by_node(np); > + of_node_put(np); > if (!hdmi_dev) > return -EPROBE_DEFER; > > + put_device(&hdmi_dev->dev); > cec->notifier =3D cec_notifier_get(&hdmi_dev->dev); > if (!cec->notifier) > return -ENOMEM; > -- > 2.9.5 >