From nobody Fri Oct 2 07:00:00 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 059AC4457B2; Tue, 4 Aug 2026 10:24:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785839091; cv=none; b=rg7kn+fIwpFSmoKnMKBrWfoAZPPsDjBoaf1hLZapIxNFs0KRFWKU6T+I9KBNcDvdwn9SPB5spJcKCtu3XBYhyWFgh6KBcg964Qau0IpfQCb6mquuU7oc7wzN5L43/cGM86uyz5oWdTWuOLP3Ka1PVEi2fWumwu5sCHa8WNX3tko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785839091; c=relaxed/simple; bh=RkqoLlcQ9b1p/kMEbFAUX8IjlgROq3QzwlTEPjY1z2k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=c6VQc/X4wNhqRr0zDHTCfMGPtK3b2FgF7zN8+OrKK5LR2oUfxPKX6DBRn+7TBV1fomcIMVImklyuZUIYOs4guazFuqPxKGSBzt/fyd5pNR/qyFbdQO7RQaMA6Sst49GVPfY8whjKRMX98uAulyzmJzJxCuxRyXRhh1ZAa9L7HjM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: b358c3288fee11f1aa26b74ffac11d73-20260804 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:85b1ad6d-820b-4206-aa59-f6162f2ac3ea,IP:0,U RL:0,TC:0,Content:0,EDM:-25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:e7bac3a,CLOUDID:df872a2cea98cf2c7b7340e03941fd45,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850|865|898,TC:nil,Content:0|1 5|50,EDM:2,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI: 0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: b358c3288fee11f1aa26b74ffac11d73-20260804 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1387231960; Tue, 04 Aug 2026 18:24:39 +0800 From: Linmao Li To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Mauro Carvalho Chehab , Geert Uytterhoeven , Magnus Damm Cc: Jacopo Mondi , Sakari Ailus , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Linmao Li , Jacopo Mondi , =?UTF-8?q?Niklas=20S=C3=B6derlund?= Subject: [PATCH v2 1/2] media: rcar-isp: Release ISPCORE resources Date: Tue, 4 Aug 2026 18:24:30 +0800 Message-Id: <20260804102431.273385-2-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260804102431.273385-1-lilinmao@kylinos.cn> References: <20260804102431.273385-1-lilinmao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable v4l2_device_register() takes a reference to the parent device, but the ISPCORE remove path never calls v4l2_device_unregister(). The reference is therefore leaked whenever an ISPCORE is removed. Probe failures after rppx1_create() also return without destroying the RPPX1 object. Unregister the V4L2 device and destroy the RPPX1 object on the corresponding error paths, and unregister the V4L2 device during removal. v4l2_device_unregister() also unregisters all attached subdevices, so it replaces the narrower subdevice-only cleanup. Signed-off-by: Linmao Li Reviewed-by: Jacopo Mondi Reviewed-by: Niklas S=C3=B6derlund --- drivers/media/platform/renesas/rcar-isp/core.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp/core.c b/drivers/media= /platform/renesas/rcar-isp/core.c index f3dc52c136120..181446ae53779 100644 --- a/drivers/media/platform/renesas/rcar-isp/core.c +++ b/drivers/media/platform/renesas/rcar-isp/core.c @@ -870,17 +870,23 @@ int risp_core_probe(struct rcar_isp_core *core, struc= t platform_device *pdev, =20 ret =3D v4l2_device_register(core->dev, &core->v4l2_dev); if (ret) - return ret; + goto err_destroy_rpp; =20 ret =3D risp_core_create_subdev(core); if (ret) - return ret; + goto err_unregister_v4l2; =20 mutex_init(&core->io_lock); spin_lock_init(&core->lock); INIT_LIST_HEAD(&core->risp_jobs); =20 return 0; + +err_unregister_v4l2: + v4l2_device_unregister(&core->v4l2_dev); +err_destroy_rpp: + rppx1_destroy(core->rpp); + return ret; } =20 void risp_core_remove(struct rcar_isp_core *core) @@ -894,7 +900,7 @@ void risp_core_remove(struct rcar_isp_core *core) for (unsigned int i =3D 0; i < RISP_CORE_NUM_PADS; i++) risp_core_io_destroy(&core->io[i]); =20 - v4l2_device_unregister_subdev(&core->subdev); + v4l2_device_unregister(&core->v4l2_dev); =20 mutex_destroy(&core->io_lock); rppx1_destroy(core->rpp); --=20 2.25.1 From nobody Fri Oct 2 07:00:00 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E3973C199B; Tue, 4 Aug 2026 10:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785839092; cv=none; b=RpvgkdCP4JW7NjaX76H+5lzklqBQKryQLW6hoXIefYYpuI+MSeDU5SzBKeGgW0BlihmBDXb1AxBjmzBoHgs9XqToqUC6Q+4XMd4e0oN4jzsnPo1DnXORNkBKo3hqTknxLNP+U4fZF/qor1Gy1UKmR9HIKPs0YJqBCL9eXeR230w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785839092; c=relaxed/simple; bh=MOiZVN9IjAsl4MH/BX6q5K88Mh5TEauMvPdpLGP77dU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lAzVhKlbliPnJbswoK440FEbWu+z5ic7JCt0ezBo6GmEIt/Vb1kWZeHI7oTLZUvFbanRzM3YO3QGShDTRqF/CTl4+F+KoBiITGrADICiq+IQmvAtsrKm+/SGkQclo3H366I5YI/dphL2q4877LXhnAcAYtbFisTAhlg+aii3Iyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: b4e498208fee11f1aa26b74ffac11d73-20260804 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:84e22f17-9ba2-4684-9a4f-d6f845452dd4,IP:0,U RL:0,TC:0,Content:-5,EDM:-20,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:-25 X-CID-META: VersionHash:e7bac3a,CLOUDID:6e5e5c39784c1ed7f11ad1803359c245,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:81|82|102|850|865|898,TC:nil,Content:0|1 5|50,EDM:1,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI: 0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: b4e498208fee11f1aa26b74ffac11d73-20260804 X-User: lilinmao@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1959304178; Tue, 04 Aug 2026 18:24:42 +0800 From: Linmao Li To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Mauro Carvalho Chehab , Geert Uytterhoeven , Magnus Damm Cc: Jacopo Mondi , Sakari Ailus , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Linmao Li Subject: [PATCH v2 2/2] media: rcar-isp: Fix VSPX reference leaks Date: Tue, 4 Aug 2026 18:24:31 +0800 Message-Id: <20260804102431.273385-3-lilinmao@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260804102431.273385-1-lilinmao@kylinos.cn> References: <20260804102431.273385-1-lilinmao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" of_parse_phandle() and of_find_device_by_node() both acquire references, but the ISPCORE probe never releases them. The device node reference is leaked immediately, and the VSPX device reference is leaked on probe failures and on driver removal. Drop the node reference once the platform device has been looked up, and release the device reference on the probe error paths and in the remove path. Signed-off-by: Linmao Li Reviewed-by: Jacopo Mondi --- drivers/media/platform/renesas/rcar-isp/core.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-isp/core.c b/drivers/media= /platform/renesas/rcar-isp/core.c index 181446ae53779..b5861d0cd0e8b 100644 --- a/drivers/media/platform/renesas/rcar-isp/core.c +++ b/drivers/media/platform/renesas/rcar-isp/core.c @@ -820,6 +820,7 @@ static int risp_core_probe_resources(struct rcar_isp_co= re *core, return -ENODEV; =20 vspx =3D of_find_device_by_node(of_vspx); + of_node_put(of_vspx); if (!vspx) return -ENODEV; =20 @@ -828,7 +829,7 @@ static int risp_core_probe_resources(struct rcar_isp_co= re *core, =20 ret =3D vsp1_isp_init(&vspx->dev); if (ret < 0) - return ret; + goto err_put_vspx; =20 /* Attach to the RPP library * @@ -839,7 +840,7 @@ static int risp_core_probe_resources(struct rcar_isp_co= re *core, */ ret =3D clk_prepare_enable(core->clk); if (ret) - return ret; + goto err_put_vspx; =20 usleep_range(2000, 4000); =20 @@ -847,10 +848,16 @@ static int risp_core_probe_resources(struct rcar_isp_= core *core, =20 clk_disable_unprepare(core->clk); =20 - if (!core->rpp) - return -ENODEV; + if (!core->rpp) { + ret =3D -ENODEV; + goto err_put_vspx; + } =20 return 0; + +err_put_vspx: + put_device(&vspx->dev); + return ret; } =20 int risp_core_probe(struct rcar_isp_core *core, struct platform_device *pd= ev, @@ -886,6 +893,7 @@ int risp_core_probe(struct rcar_isp_core *core, struct = platform_device *pdev, v4l2_device_unregister(&core->v4l2_dev); err_destroy_rpp: rppx1_destroy(core->rpp); + put_device(core->vspx.dev); return ret; } =20 @@ -904,4 +912,5 @@ void risp_core_remove(struct rcar_isp_core *core) =20 mutex_destroy(&core->io_lock); rppx1_destroy(core->rpp); + put_device(core->vspx.dev); } --=20 2.25.1