Received: from endrift.com (endrift.com [173.255.198.10]) (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 1ABC51D555 for ; Thu, 19 Feb 2026 04:22:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=173.255.198.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771474945; cv=none; b=a58pHF1CTqJz/WSB0EZGNUzOSrHGclBHPGhWn7qjwNqoVmukIAf0DqSuGNQuesLJB18jO/rYb4SuoztyFLeWRi9zrrv6ZTO5jI6rJdAyDsc4pjLR+k/J5uRGYRzUWVZvP7UIouLgMXapNiGkHZ+/2s86BS47rR2dS51avz85XdM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771474945; c=relaxed/simple; bh=QmiFeMIwm6MIH/qQ2FxjOtiA9u5JvtUZbYFDszf6Jcw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K9P85L8Y553R3vxohTf9rTG9q/f2e8rT475njhw13DmP/jJajG/QpOn/fITqQzpZMt97UJl4egqE7Q5SRMT4SyOQkRYXxkcmzQTq7e8pVQGKcFUpJ2CVLNsb7eEUj8gj7rMggZ6JglPcKmpek/5FQP3al5yLeC41oz3mO17eBEQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endrift.com; spf=pass smtp.mailfrom=endrift.com; dkim=pass (2048-bit key) header.d=endrift.com header.i=@endrift.com header.b=z2SpYNyn; arc=none smtp.client-ip=173.255.198.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=endrift.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=endrift.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=endrift.com header.i=@endrift.com header.b="z2SpYNyn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=endrift.com; s=2020; t=1771474458; bh=QmiFeMIwm6MIH/qQ2FxjOtiA9u5JvtUZbYFDszf6Jcw=; h=From:To:Cc:Subject:Date:From; b=z2SpYNyn6mFnAhEXq87SZ8dYObZ/7082H6gPwmqB4MlE4ZYltrFDlUQ09myFrMKfV qrfOLFQHpCvVPfbVgfjWMQGtYhWA/Xdly10vDFRq8AwZcusnjA33dpuWAsSSU5cuvQ Ci1Lakt4NM5dYC52Nhhd6hiFNcrflKsso6Liye+HWw1ovqlNlvvfgghBYPxUD3vd1i 0NIA3nVLp6b71OlM4vYBlNsFLK4jxv8pIt0+4Vm9wM7LEJulhCP5lDhdEGr/WihkQo n4nn8uZ/od1OrjKefj5kZF31DnI+oQyB3UyJmPD0Sq+jDbt3U4ji0umAAYCuAUjHcb XE+Jrw4/nwnjQ== Received: from microtis.vulpes.eutheria.net (71-212-14-89.tukw.qwest.net [71.212.14.89]) by endrift.com (Postfix) with ESMTPSA id EB7FBA041; Wed, 18 Feb 2026 20:14:17 -0800 (PST) From: Vicki Pfau To: Hans Verkuil , Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: Vicki Pfau Subject: [PATCH] media: pulse8-cec: Handle partial deinit Date: Wed, 18 Feb 2026 20:14:08 -0800 Message-ID: <20260219041410.608067-1-vi@endrift.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In the event that the cec dev node is held open while the adapter is disconnected the serio device will be cleaned up but the cec device won't be. As the serio device is freed but the ping_eeprom_work is not canceled, the next ping will still attempt to send, leading to a kernel oops. This patch both cancels the ping_eeprom_work in the serio cleanup as well as checking to make sure the serio is still present before attempting to write to it. Note that while the added serio = NULL line looks similar to one that was removed in commit 024e01dead12c ("media: pulse8-cec: fix duplicate free at disconnect or probe error"), it notably happens before calling cec_unregister_adapter, and as such shouldn't lead to the user-after-free that removing it fixed. Signed-off-by: Vicki Pfau --- drivers/media/cec/usb/pulse8/pulse8-cec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/cec/usb/pulse8/pulse8-cec.c b/drivers/media/cec/usb/pulse8/pulse8-cec.c index 60569f1670fe5..67834ed333d32 100644 --- a/drivers/media/cec/usb/pulse8/pulse8-cec.c +++ b/drivers/media/cec/usb/pulse8/pulse8-cec.c @@ -235,6 +235,9 @@ static int pulse8_send_and_wait_once(struct pulse8 *pulse8, { int err; + if (!pulse8->serio) + return -ENODEV; + if (debug > 1) dev_info(pulse8->dev, "transmit %s: %*ph\n", pulse8_msgname(cmd[0]), cmd_len, cmd); @@ -655,6 +658,10 @@ static void pulse8_disconnect(struct serio *serio) { struct pulse8 *pulse8 = serio_get_drvdata(serio); + cancel_delayed_work_sync(&pulse8->ping_eeprom_work); + mutex_lock(&pulse8->lock); + pulse8->serio = NULL; + mutex_unlock(&pulse8->lock); cec_unregister_adapter(pulse8->adap); serio_set_drvdata(serio, NULL); serio_close(serio); -- 2.53.0