From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE5BD42DFE9 for ; Tue, 28 Apr 2026 12:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777381040; cv=none; b=fhd8kM9I2/PvIDuvao2sbZ55h2qBCXuIbSyUubKFjJFh20+0AGR0xLsnJEY5MAvryIUdbOz3386cFkUdQugU8Foc64+n76vq0XkUDwi3Wm58DCksRwJORa/VcehcpTDvpzHZ6rDCaIInxn14MMdf1IEw3i2A2bOhW/a9IUCFn0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777381040; c=relaxed/simple; bh=VqeLDQRLMKU7s+EZS+ig8a/zapOpnhK489qRigdsGcU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lTymDogwL5eoUuIXiGBgO0HiJNcZn3rmIhmjEAJFzCqMIFRfM4QQ+0WsDkF9JhY2rcnyr4mA4X8hcAP+Qhx7ST8hMacigy6ovcN/VVyK75lvUdyFt5DJFU+DlTPL4CjY2RxypZi5E4k3iU4lLt748ndkYpgsl6e+zxoquBmhzZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ErnTEDRi; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ErnTEDRi" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2b4583f0a1aso71813045ad.3 for ; Tue, 28 Apr 2026 05:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777381036; x=1777985836; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9ZBVJ20UhMxUS07PwK3D+4nyCgSd/sgxQDWyRFPlgUE=; b=ErnTEDRiERA4qEU89zuDMOY8E+K0ICn72917+vcp5no0B2eiRCBOOcDQWNZpPrRJKe aB3fjwkxkxUYhXiiHax7hjK1wnoDGnuee/sq2ui5NRJekBjqCKBQkqkXGjKgEIC8PRLf Q58DDXHVBfwBBkqVO0fKW7iW6X31Bkv7YE82fPur4t08dYIqynf0iBZaNZqpSlJqZ9DI 5Lcbehv2RVY1C5A9RwDZGF0w/8nsSf/x9GdgxtYcuZhfwFBmnLmu7b0/tG2o8yY980RN gUSKt1Wg8XYhnk8iEZbZvQXA/0/kiDPiFugnwZHvCu5Ok9Edbhg/a+tZya3OnNDs5iF0 1Qog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777381036; x=1777985836; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ZBVJ20UhMxUS07PwK3D+4nyCgSd/sgxQDWyRFPlgUE=; b=c43K9dzorA5cTJZp3n11BIezwRa9QWnVoiRVEL9u0fwlP93oyxgEwJtnkoBtwIhN4A vAJ+akn0DHZKQQNwTbYPidauWriRHNxBMeRGX+KobQSBmO0aImt6AYGH5Jl/ahzJuDfy 3k2l/pZO2Ftx6kNJqEioAaVZx+2FNZqzFcjWJ/mHVLqd/u9oaJvhH7918FyzP7Ew9al1 UW4JBwqz5RafmYC3UVyOmx+zl2khyLW3N2hGsSP0N9EADLMfNykKDJQSnqKbz0vWBpV+ 6sBaCIiLX/X9BQ0192ThU+iGNur5AoDTvnrdsMfr4I0nPXeR3VjljNdUsJmlV5eNZLbs 0uYQ== X-Forwarded-Encrypted: i=1; AFNElJ9N9ZZhYMiviRoCsQAKTmIiYaMwp8CcY9cKLL/hRAqUYuN1iMfcIlgPhK8qp96Oph+wNEw27TuHvVATceE=@vger.kernel.org X-Gm-Message-State: AOJu0YwfDcKUB3tV9NhWLhUHMNeoW3wOPAQxC3H0gS9R5iNBk2EO+a5q As7Bru/4hO7Iaz+ZpU+Neh00fRkkagr3I4uTfII9OCSieauDwxVEilLYsxp3GNlU8A== X-Gm-Gg: AeBDieuK6+8ZmffXqLOvNk8DqnfwgtOs4Rixi1mZUOmtnzIUjTkJY5GF+dfPajt/FBL S+Ik6UthOKLwaAadafOpFNDxaN0o9AO7D8BW8RDFLf6KieLt/9ZXSIlGSo5TmaaHRyVZ7cXCS72 FkZfHhqu/veemDfYk95UouoYHsMxwsvyZRpJPfg++oioypACIiMS8XS2K9aDhGLXgUjv+SEIv5X O/Uiw6r0dslN6FE7XF6CyCWckvVpTftl6oGMpd56GoRFBgTDdzj1ZER71Y8hALCo9ocqAe1EKjn bQVWOgDC/QAEaQVbiRv53JMWq6vF8zYznFWI32gOuQ0unEe2jaGwkXLavCLf/0NysyWF9mQX/4J Cm4I0l6kWz4gaV3+HByjcOzZc+3AiMkDShLbzQfqZtCjXhPyI3SD6tVGUbCwhSF3+nyVjSaHNss 5dSROxs2btWIgEIfShYPYgXj3DtlABxENEgKpoJ5KJ5fqF9BKhV5K/xjFeJMn5rnL+m6fyawOUj ss1WGy7/RtLz/k= X-Received: by 2002:a17:903:1b2c:b0:2b2:a267:784a with SMTP id d9443c01a7336-2b97c47b88fmr29441165ad.24.1777381035694; Tue, 28 Apr 2026 05:57:15 -0700 (PDT) Received: from localhost.localdomain ([1.226.165.54]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b97aca8b4esm26483825ad.73.2026.04.28.05.57.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Apr 2026 05:57:15 -0700 (PDT) From: Myeonghun Pak To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Cc: Myeonghun Pak , Mauro Carvalho Chehab , Geert Uytterhoeven , Magnus Damm , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Ijae Kim Subject: [PATCH] media: rcar-vin: Clean up notifier on probe failure Date: Tue, 28 Apr 2026 21:57:04 +0900 Message-ID: <20260428125708.93102-1-mhun512@gmail.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rvin_group_notifier_init() initializes the group notifier before parsing the graph and adding async connections. If parsing fails after that point, the function returns without cleaning up the notifier, leaving the async connections and their fwnode references behind. The Gen2/default probe path also fails to drop the group reference when rvin_group_notifier_init() returns an error after rvin_group_get() succeeded. Unlike a successful probe, .remove() is not called for this path, so the probe error path must unwind it directly. Route notifier-init failures through a common cleanup path, clear the cached async connection pointers after cleanup, and make the default probe path mirror the CSI-2/ISP group unwind. Fixes: 856b49c71ae5 ("media: rcar-vin: Merge all notifiers") Co-developed-by: Ijae Kim Signed-off-by: Ijae Kim Signed-off-by: Myeonghun Pak --- .../media/platform/renesas/rcar-vin/rcar-core.c | 32 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c index c8d564aa1e..8ba8d49c3e 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c @@ -318,6 +318,20 @@ static const struct v4l2_async_notifier_operations rvin_group_notify_ops = { .complete = rvin_group_notify_complete, }; +static void rvin_group_notifier_cleanup(struct rvin_group *group) +{ + v4l2_async_nf_cleanup(&group->notifier); + + guard(mutex)(&group->lock); + + for (unsigned int i = 0; i < RCAR_VIN_NUM; i++) + if (group->vin[i]) + group->vin[i]->parallel.asc = NULL; + + for (unsigned int i = 0; i < ARRAY_SIZE(group->remotes); i++) + group->remotes[i].asc = NULL; +} + static int rvin_group_parse_of(struct rvin_dev *vin, unsigned int port, unsigned int id) { @@ -440,7 +454,7 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port, /* Parse local subdevice. */ ret = rvin_parallel_parse_of(vin->group->vin[i]); if (ret) - return ret; + goto err_cleanup; /* Parse shared subdevices. */ for (id = 0; id < max_id; id++) { @@ -449,7 +463,7 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port, ret = rvin_group_parse_of(vin->group->vin[i], port, id); if (ret) - return ret; + goto err_cleanup; } } @@ -460,11 +474,14 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port, ret = v4l2_async_nf_register(&vin->group->notifier); if (ret < 0) { vin_err(vin, "Notifier registration failed\n"); - v4l2_async_nf_cleanup(&vin->group->notifier); - return ret; + goto err_cleanup; } return 0; + +err_cleanup: + rvin_group_notifier_cleanup(vin->group); + return ret; } /* ----------------------------------------------------------------------------- @@ -1228,8 +1245,11 @@ static int rcar_vin_probe(struct platform_device *pdev) break; default: ret = rvin_group_get(vin, rvin_parallel_setup_links, NULL); - if (!ret) + if (!ret) { ret = rvin_group_notifier_init(vin, 0, 0); + if (ret) + rvin_group_put(vin); + } if (vin->info->scaler) vin->scaler = vin->info->scaler; @@ -1264,7 +1284,7 @@ static void rcar_vin_remove(struct platform_device *pdev) if (&vin->v4l2_dev == vin->group->notifier.v4l2_dev) { v4l2_async_nf_unregister(&vin->group->notifier); - v4l2_async_nf_cleanup(&vin->group->notifier); + rvin_group_notifier_cleanup(vin->group); } rvin_group_put(vin); -- 2.49.0