From nobody Mon May 25 05:13:13 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 D01083EF0B3 for ; Mon, 18 May 2026 13:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779110222; cv=none; b=bBV5EgQ+cs0llVyDdA8E4gjHnkCynyJGZ16LEH3iTnkHL6b85VbHh0kf9oLL/jkj6gW5iiVjhOWJJyv6+KLi+UouoHOKUhBeDRfhywi1EsoStHZ8jrr2uUwBOOIKfaJzbGdrf6kNKkiC8XtPGUydnZwgJTpT41RDSsyCOKd4ZQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779110222; c=relaxed/simple; bh=F50kce7m820nEJNgDTgDV7dt2jZ6kHeIKBH+7d3Bynk=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=tVzsC09abNfE26qWp3jzoLLYL6kYrP7eMLql9YRze8Cg4viHtUP5TtF4ecV7yZUUAxeKBLahduRLggnaRYF4I0Qi7XB7Bg+X5rNQnejIs8qIS70FvZVVTj/SNB7p0RWg5NmYl039dPKw9pzs5nwIv3tJS2g9BuVYy7JdE/SehLM= 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=VmDnsxRx; arc=none smtp.client-ip=209.85.214.178 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="VmDnsxRx" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2ba0714574fso11611675ad.2 for ; Mon, 18 May 2026 06:17:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779110220; x=1779715020; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=TQnatVKvAZ1AidZJ+dfL02Tnt1fpmvrVA/OGueI656o=; b=VmDnsxRxt6qyUW4gBUG6Ld+aVmf/ZTc6GG4Di4+J60vvRG9iTmPICl47Z46fHI6iNg DV/BeuVSUZkFSRiw9qMfvXQQ/TsMnesyj3/6+ZJShN8G1FDdeDIbIFNCQpC00YFrPapJ bWqR9ZsenkxVFFuPYO8zfUe7qQDnqKLCpHXipfHtlD3T3UMGAWfO78bZmSh2SjgIB0Pn hkQUadQ2KlftsPhzzJbzzvy9kf3gnnIAxGPGYY5hYyso37FvElg3thOuH0UjtPuYH1gf cAtoeq7PbKlAZRgRZ8y7W2DBSQPUrWVTJ6TO00m30WiBuxLknlfSlIXLNp5ySnkwnPg8 q3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779110220; x=1779715020; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TQnatVKvAZ1AidZJ+dfL02Tnt1fpmvrVA/OGueI656o=; b=lS41EiGDC4Mmv4fbPcwn85ODB1l88iYDtPWLrHEj5O7/SILO8SIwcLVtGSmqHLQPzw 1AUNACFu0oOQY15tOiWMcma8YieSSKaSm3TXniazUaj0doc7RooSiwjEYzqXkyvDzx0B Jl/MI2qBNR/qyfeohZkIpmTzMkS1NvVUR8D/rLAI1RS3W0xYROSiQS4mW9+FXdsuq8RX jB8XLqs4Hce8J3t2MHH+4zxQ94feL+o0FlnhavzreOvOjqJuDVZ3SMiUMROUORWgV0Rj 71tDkWytL1Vo34AnrQihJTmkriIrusjcaU9OEFILW2kN3oX6pZlPkUSlsqpxxRUeIN7K MvpQ== X-Forwarded-Encrypted: i=1; AFNElJ+M3rUpcTJ2FDEbrGmJmzwBmm8abYFBrommh1A0b0YMwNbHmz3KrGfs+BQ7JDC1tUEvj8tr8EvSsTP/buQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwBgwAdSgO+b9ZyP03pkGL+x+m0kMl8V2tj1q6gdAJNZ0OowZv2 hMuCU2MYGmIFNGhmNsNUPwI6oGvxXZK1JI9OgrM7calbLcV9CD5f8v4w X-Gm-Gg: Acq92OFA9gkO8+EzzAs0z7Ij4aPjyf9aW1AENbUV615J4fOHUaU1NJ+9jnNCiHtWddx TsM3b9fMwG0npTwI6/gmz0FUgL8N2XaZ88aLHw6JNP5m0H/ig9yrAEZo93n8qukecAxsnKV6C5U fYRmWeMNNfz9+DjNuaLhxflR9eHUZqolLUXikqsXubRGTrkrl8q8jCPZM5vlHHEzniQmwSM2dRc llEp6Q85oFR35JtDfOQK7Ik/EJlGo2pD6QNoJUdZgmhwKt+7vq5PnrK9USGTI7kE4Nt9yQTml26 MStnyPZHfmNETlMOeIb/Hny1T/CjYw06Uz85TCLMYoXESQgKn3xe6Cyghdo1WZg7YjO7syPCU6X qVZ6tm4XP3O1Fpf4ueLfN9p6caogyVMpy93wf2291sfIdxtjLLJ9gSXDG0D2tLGoNMa9dpvdrJM zBcZk9Ow== X-Received: by 2002:a17:903:3ba4:b0:2b2:ccfb:8387 with SMTP id d9443c01a7336-2bd7e9769edmr171166715ad.28.1779110219919; Mon, 18 May 2026 06:16:59 -0700 (PDT) Received: from lgs.. ([2001:250:5800:1000::f280]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bd5c26355csm149573365ad.35.2026.05.18.06.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 06:16:59 -0700 (PDT) From: Guangshuo Li To: Mauro Carvalho Chehab , Kees Cook , Laurent Pinchart , Hans Verkuil , Guangshuo Li , Jai Luthra , Muralidharan Karicheri , Vaibhav Hiremath , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: omap: vout: avoid double free on video register failure Date: Mon, 18 May 2026 21:14:12 +0800 Message-ID: <20260518131412.1005805-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.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" omap_vout_create_video_devices() registers a video_device and releases it from the error path if video_register_device() fails. This can double free the video_device when __video_register_device() reaches device_register() and that call fails: video_register_device() -> __video_register_device() -> device_register() fails -> put_device(&vdev->dev) -> v4l2_device_release() -> vdev->release(vdev) -> video_device_release(vdev) omap_vout_create_video_devices() -> error1 -> video_device_release(vfd) Use video_device_release_empty() while registering the device so that registration failure paths do not free vfd through vdev->release(). omap_vout_create_video_devices() then releases vfd exactly once from the error path. Restore video_device_release() after successful registration so the registered device keeps its normal lifetime handling. This issue was found by a static analysis tool I am developing. Fixes: 5c7ab6348e7b ("V4L/DVB: V4L2: Add support for OMAP2/3 V4L2 display d= river on top of DSS2") Signed-off-by: Guangshuo Li --- drivers/media/platform/ti/omap/omap_vout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/ti/omap/omap_vout.c b/drivers/media/pla= tform/ti/omap/omap_vout.c index 8d0319a37ba8..691f97ac5ed4 100644 --- a/drivers/media/platform/ti/omap/omap_vout.c +++ b/drivers/media/platform/ti/omap/omap_vout.c @@ -1501,6 +1501,7 @@ static int __init omap_vout_create_video_devices(stru= ct platform_device *pdev) /* Register the Video device with V4L2 */ vfd =3D vout->vfd; + vfd->release =3D video_device_release_empty; if (video_register_device(vfd, VFL_TYPE_VIDEO, -1) < 0) { dev_err(&pdev->dev, ": Could not register Video for Linux device\n"); @@ -1508,6 +1509,7 @@ static int __init omap_vout_create_video_devices(stru= ct platform_device *pdev) ret =3D -ENODEV; goto error2; } + vfd->release =3D video_device_release; video_set_drvdata(vfd, vout); =20 dev_info(&pdev->dev, --=20 2.43.0