From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 4F0223B2FF2 for ; Sat, 8 Aug 2026 11:05:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786187139; cv=none; b=STO6fy3CtQ7wLRF5+HPWhzpBkoMvedAVrJKwfdgKAryUuyihN63dwmr4lVlfyU1aF2rHetUegCuCUMdgyGxS62RnttrRHPZVcfjGcN7VfrH4a4LZzH+VRyetaqogJyjwyc5OvNxCRvg6P4gV/fLJTPkeOmHI1A1lhsYcDuqbig4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786187139; c=relaxed/simple; bh=ogdIvbW7aSb4932xDfimt07Z3LRdmf4GX30hP45/UL0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IFJR/ToTq1BFQ63LNoG1tEwbyg6Ww5ISJehc53M4qRROpfdFjVm8IhTVbyo0RY0WYD41QUpmzS0+4wxyblrl+2CAnHVeihFbW+GBseVuKrW7V0UVRYn4tjvdm476Lc73wIg0JUE/8tuyjAJpN5SccigsR8qk5Pu02oWYJGl/EUc= 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=Jdbe9jyU; arc=none smtp.client-ip=209.85.210.179 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="Jdbe9jyU" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-84874b52eabso519147b3a.0 for ; Sat, 08 Aug 2026 04:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786187137; x=1786791937; 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:content-type; bh=vd3mCxZmxHBD2Xo74+SQgSYvrRmOoQOdDSC9aBG9aE8=; b=Jdbe9jyUHHCEz96IjgllbO/0jPqe5WO4S4irUyOAQbmMgBfgjHdSbOj+UUrrAKLIR6 MpLOinJ4soF1X01DnQzt/d371EmZ6ZqmDzBBgBd8axUeM42oLutCmU175muF0AjdIOqO nllcIiYIzkf1aVrndDSssyDkI0lGluwWOVjZMk0kVef11TwETlYxlXm3w66wmnEXyM74 KeahWTaJKpWw/Sf3UIFYgRm8613CfRONW3OTQl8ZhyIZJeoQ1SSsZkdcbj+H+BuABVr/ e0CQsqf5oHS+61I4uG/hMHfXSj/YwnZCp7XgfYtm/V+bk1t4gWVkpo07Hkh5PDl/vvUW MMPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786187137; x=1786791937; 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:content-type; bh=vd3mCxZmxHBD2Xo74+SQgSYvrRmOoQOdDSC9aBG9aE8=; b=sPUePvxOZx+g5trILuDZI/lO/Ifw94IbyFKXW+0bptCvCGDh3KPlpV16IOEoixqhAW 07xIzlI8fct/V6Bici1rRpC4Am36mOmHqXKyxt6kHBf3lfYhyiKJ51eE9bafMWPKQz2L tA2d1svr/BLDS70YJ5tvUDEV6iZwJMdWe/lanupIQb7WlPIVN5CHcfivFGDaPEsdV5gC XS1kHWaKoYgshJmrkjoreZEXjNuHFzIH+enxN0Mt2MoaG+lYkLcHmy35kHpj89aK06Jy DPNLucuF9397435woLn+thv/c80npUbIoxV1Vcpz5O89W7usw0WwBrJmzyt9bl9CNLgb ujaQ== X-Forwarded-Encrypted: i=1; AHgh+RrCOnIueCU0N8xinUxm2XoyZsYn5HspWCOpwKb/byMku7T78U6pdFLY6UvDK8RXRUgKsivh9k82FacPOMA=@vger.kernel.org X-Gm-Message-State: AOJu0YwgLqU/34bDPYxQf8P+LhzntKNEwOv52CnbLXasVVfEjolXIi7c wd0Nlk8eDmLwX/IMIFqiWWNnVdXTpZFvqGNE40/nl/4eZamWnmzePHnO X-Gm-Gg: AR+sD11JfL3A3U1RHc1ayd8+eb78fEq2H8nB6nMRn3H+ZYBYdZ2EHQ2IhzejrfkhaiS +NaepC3N4OEkiUtE4F8f/86V1r197wh6W5HNEcQMU+9GO0XbiYAWYWCJJ82+FJI+j1hiKbnUR7f G8W/rOX1FCGmhbTra8rTXs09wYzQ1LD3dXHRRUKUUIJDTSAe3wEPdw+kf8hrCqXjhA7M8Z3ubzp /vKkTjKqghBA8uF2btLGm9BLojHYZT1ml6z97O8PC3sqnJSvzxhoOgH3gFEB8uvNZ0vXoqzKfiu MBt4r/GO7285Ry6i4DD54XfyUF8RTJFTl79tpMSXn5mMEpyYKD0hBaLIZgOPAM65lBumDW4wwBh OBLYVqPqoAaxfwhmzWdD5NCDwwGHet6TlgKTLJkMG237x4+mComGSlTID3JzOm/1UhMEd38wY+O t37N9PePmjcKyxA+6Xc/oCiEf35Ojujk4VA7bNiclJU5lrzLA8qiWr9/hBPF0ZqHmKkgWRq5meF NT8WQ0BuRwZn2x3 X-Received: by 2002:a05:6a21:6817:b0:3b7:aefe:4367 with SMTP id adf61e73a8af0-3cbc0490091mr12371196637.33.1786187137473; Sat, 08 Aug 2026 04:05:37 -0700 (PDT) Received: from SGN-LDSENG.tasernet.com ([2405:4800:5cc3:11a:1ac0:4dff:fe8b:4a69]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-315bec2ec20sm21643469eec.28.2026.08.08.04.05.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Aug 2026 04:05:37 -0700 (PDT) From: Cong Nguyen To: Maxime Ripard , Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Cong Nguyen Subject: [PATCH v1 0/3] media: sun4i-csi: fix lifecycle bugs (leak, IRQ, unbind) Date: Sat, 8 Aug 2026 18:05:26 +0700 Message-Id: X-Mailer: git-send-email 2.25.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 While addressing an async-notifier cleanup leak in this driver, I audited the surrounding device lifecycle and found three separate pre-existing issues, all present since the driver was introduced. They are independent of each other; this series groups them because they touch the same driver. 1/3: sun4i_csi_notify_complete() registers the video device and the bridge subdev before creating the media links. On a failure in the later steps it only unregistered the media device, leaving /dev/videoX registered. Since probe then aborts and the devm-managed context (embedding the video_device) is freed, an open() would touch freed memory. Unwind the registrations in reverse order. 2/3: sun4i_csi_stop_streaming() stops the capture engine but never disables the frame-done interrupt or synchronizes with the handler. A late IRQ after the block is runtime-suspended (on release) can access gated registers and crash. Clear CSI_INT_EN_REG and synchronize_irq(). 3/3: The async notifier ops lack an .unbind callback, so csi->src_subdev is left dangling when the remote sensor is unbound; a later STREAMON dereferences the freed subdev. Add .unbind to unregister the video device and clear the pointer, matching stm32-dcmi/atmel-isi/mcam. All three are marked for stable. Compile-tested (COMPILE_TEST) and checkpatch --strict clean. I do not have the hardware, so testing on a real A10/A20 CSI setup would be appreciated. Cong Nguyen (3): media: sun4i-csi: fix video device and subdev leak in notify_complete() media: sun4i-csi: disable interrupts when stopping streaming media: sun4i-csi: add notifier unbind callback to drop the source subdev .../platform/sunxi/sun4i-csi/sun4i_csi.c | 25 +++++++++++++++++-- .../platform/sunxi/sun4i-csi/sun4i_csi.h | 1 + .../platform/sunxi/sun4i-csi/sun4i_dma.c | 11 ++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) -- 2.25.1