From nobody Tue Jul 28 22:59:43 2026 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 98AE047CC91 for ; Wed, 8 Jul 2026 14:33:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783521237; cv=none; b=bmtGcm0pfl5YGvs3o7htvfG16PpeYFX1fVLL/ZPY0HxEIh/nS1w0DXEYwP2xgEa9XTqZpHk1q06lRDO26P7BdooYu4nJ/kvYoUy5p+n3c1j2kNzAhFTS/46qZe6cyqSEOKJxEQy28vHUVUo2mr9r68hBCEkI4cblZwN1QIi754g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783521237; c=relaxed/simple; bh=0182PjDLqJYH49u/fjuLXwsDJ9qx0if1Stnt9C5AUFI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ePzq4Ty8e66xviHttSvhIIp57jQ3QzdhyHwnt9vOvyOK8gMdMsJTQqFQLC3aLLLgBK8U5WWAAr6A9Xo/bTuj+zMzL2mEvPxTRUFmZALBKVNLqeJJI/Vq3TIgfehJtHM1YV2ag1Wr69GLlEwXfldNTKcKAr6zdejff24V42skDQM= 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=iIuE+q26; arc=none smtp.client-ip=209.85.214.173 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="iIuE+q26" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2cab973140bso9837115ad.3 for ; Wed, 08 Jul 2026 07:33:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783521235; x=1784126035; 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=X9lPE0ZoKdFyqGtNh/DJcalm3aGhMh0M5cKf5v8Qn7w=; b=iIuE+q26W11O2vhQUVBeIWwdHP97OW5TlAfkKWRu5ZAHLGLhmC3iy89QRoRs7Sxl1j 6lQN5Jib+eKPF1VZ2PzacB/juMlnD5K3AbHVYFqZ/vtVJFtootD4xC8zE4DHPSkJ2GYJ q87UjMMjaJRnHQWjUrZlczcYegwsOg46WvI8RYO9oBIEfwJXnn/fSSeM2YmjayKCl9CN GX8wLyQnFjJq6VYGk5Pl7StcqqqyhZXFDOHrLz69OHEQlq1O5Q0txp8Kl8DrSpQsKhUP dfpKv0P3g0XTk5viD0r0Et9Az1orHi6SdYEur4QIUYbeTPmueswo0TBI1ZHEjpWX+jKA m0Eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783521235; x=1784126035; 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=X9lPE0ZoKdFyqGtNh/DJcalm3aGhMh0M5cKf5v8Qn7w=; b=a8C0Abq97a9SSUfaATiu0Q+zMGNfmxDQJJyfppcP96pFdMnskzGoTzVbDvtl04XSBP vjyY67EyQANjF/rkm08W8pK+AAgHKvePSZN6fSm4Szccw1B1o50DkPr1nA7d4uc3v4xS G2tkKBaRx5hv/qojx6bOFscHoR/i4FvZ/mHu0HGWx8x2pjg6pPUQ0rD7/ADbmdy26ZWv L/1yNu8DqZ55/umMhUYmw7lDIiuwLNlJx91idQ0/0KdAg1BKpnVn7/mdCTLga/o5ilIE X6Wv8Jg4ohmWRNzJ8xMMGtpxCQm5UvwN9fTR/5eH7jbFz+2/l3BME9HP74D/xJ7H5aRu IYJQ== X-Forwarded-Encrypted: i=1; AHgh+RqD0P1uhru+pvPbsX0pZ8rWsbGS6cmuY6+DE0WRsqLMz1tiW7X30IIRfCqxqltKsjTKbB+GPTn+AqduiXs=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl1Zd/R0fIcfvlxcHGE08dPZ9FahSiu0MQqBRwt9Mz35/68zQE qgfT02juE1AMlfDPgRRRJQ7CMgjKDxST73VYDxiVX/B8vSCkjfXGWE0v X-Gm-Gg: AfdE7cnfQ62HyixQvTo9Nw8ImqGdMkVyLdfoX1hW5SZhRX8BOKD3PEIDztGX3hQK/4f Z2Iiut+D1dyCG1vssnqDOj3M2edh4DLoLMicEcpOutHNuOFsWctDoR+6OR2/Qp+av6sAb7qfB+r 9x1OerDvETNg8cZzMZNHQMpzfWzWAWu+atS6EqMesbvmXldau55HmNoTIlrFieMucQJ2NvGrItn kL2K2se9wS/ZkN5CHkLuxDRC0B78VFsb9sWMARIkze3TSTdNrZ+uogCPT82u+f1jQjCjfHIqV2r 1VDULevkkpz24ks47Ul9sVhn/QARm/SVIEvmMg+lc1jZtMVpUBNKe+hymfXE2g3AzFnw4cACtNv 6POtt/KeWnkLtQ6CcYFStR3+yTgqAjl+9/aRVjZ/hLKTz6mnhd4gU8TsUlDOTqBURociQaZx2ME 5mM50mZQd82qhciEUG7cOkddDMNI/QUidR X-Received: by 2002:a17:902:f547:b0:2cc:7c36:2c23 with SMTP id d9443c01a7336-2ccea484f93mr31372975ad.43.1783521234909; Wed, 08 Jul 2026 07:33:54 -0700 (PDT) Received: from haichao.tail057a43.ts.net ([2001:da8:e000:1206:1b95:b995:f60c:5c67]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ccc9bdb877sm29139605ad.14.2026.07.08.07.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 07:33:54 -0700 (PDT) From: Ruoyu Wang To: clabbe@baylibre.com, mchehab@kernel.org Cc: hverkuil@kernel.org, mjpeg-users@lists.sourceforge.net, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Ruoyu Wang Subject: [PATCH] media: zoran: Avoid freeing a registered video_device twice Date: Wed, 8 Jul 2026 22:33:49 +0800 Message-ID: <20260708143349.3166015-1-ruoyuw560@gmail.com> X-Mailer: git-send-email 2.51.0 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" zoran_init_video_device() installs zoran_vdev_release() as the video_device release callback through zoran_template. After video_register_device() succeeds, video_unregister_device() drops the registered video_device reference and the V4L2 core eventually invokes that release callback, which kfree()s the video_device. zoran_exit_video_devices() called video_unregister_device() and then kfree(zr->video_dev), so device teardown could free the same video_device twice. Remove the direct kfree() and clear the cached pointer after unregistering. The pre-registration failure path keeps its manual free because the video_device was not registered there. This issue was found by a static analysis checker and confirmed by manual source review. Fixes: 82e3a496eb56 ("media: staging: media: zoran: move videodev alloc") Signed-off-by: Ruoyu Wang --- drivers/media/pci/zoran/zoran_card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/pci/zoran/zoran_card.c b/drivers/media/pci/zoran= /zoran_card.c index f707bdc1fb0f1..b8285df644738 100644 --- a/drivers/media/pci/zoran/zoran_card.c +++ b/drivers/media/pci/zoran/zoran_card.c @@ -885,7 +885,7 @@ static int zoran_init_video_device(struct zoran *zr, st= ruct video_device *video_ static void zoran_exit_video_devices(struct zoran *zr) { video_unregister_device(zr->video_dev); - kfree(zr->video_dev); + zr->video_dev =3D NULL; } =20 static int zoran_init_video_devices(struct zoran *zr) --=20 2.51.0