From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CB8F15540AE; Wed, 9 Sep 2026 14:29:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788964148; cv=none; b=ZufmBwZR/ujt6LshNrcTWzMUISPAawz6fnAwgJj90abhVsBNbiMGApQJmwqM6xx2FgnCpSuZh/9tIqpcuROuW3sXlcfgUFw0rOCU8tn2x/JJp+way9pv40ncGTRgNJkE1OkxerZkY5bFpAUXvdM9s7r5Z80F33gNXvJxgi3BSY4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788964148; c=relaxed/simple; bh=wstWoLLgKrEMDUp0mEickI4dx/KMrMFtehPLBHnXlp8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fgc6R7D+cz9TubT5KRW6C6iunjLafVgRGo502wp6POenffMxWft+JhKZTSqwNXgOmc7u7TIbEnkfTSOT/lRpgDEMhEGkxn1xPaGk4AH4dfTOymEOe7C+AFuL2yd+2GXupN/nAE0Z3I1aITB+ILxkm6PoGeJmfi23JKPC8wDp6kQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lempd+SX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lempd+SX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27FDB1F00A3A; Wed, 9 Sep 2026 14:29:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788964147; bh=PlO7qAII7LFrZmArFfkHEUDj0GWyRUzJ+pbF+yIBRIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lempd+SXXjhzH/QfIptITztYBSIonOdRQHc9VOhm/Ybgeat7EzvqwpMftPiMpWUBd 7fPx2uqwSiGagzzbYRbFyOLZeFG3HoZyvjVM7n1HI9wViW63LMEMvwuzKip6vnlDiF kTw039B6DK9iTzhnVsG0vqgDfeFI+da/z97AhbJA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Uday Khare , Hans Verkuil Subject: [PATCH 6.18 316/583] media: video-i2c: fix kthread error pointer left in kthread_vid_cap on failure Date: Wed, 9 Sep 2026 15:40:01 +0200 Message-ID: <20260909134248.953999606@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260909134237.773280130@linuxfoundation.org> References: <20260909134237.773280130@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Uday Khare commit 76e379754ba618989f6215be608d5c04774a611d upstream. kthread_run() returns an ERR_PTR on failure, not NULL. When start_streaming() fails, data->kthread_vid_cap is left holding this error pointer instead of being cleared. This causes two subsequent bugs: 1. A future call to start_streaming() sees a non-NULL kthread_vid_cap and returns 0 (success) immediately, without actually starting the capture thread. 2. A call to stop_streaming() checks 'kthread_vid_cap == NULL' which is false for an error pointer, and proceeds to call kthread_stop() on the error pointer, leading to a kernel crash. Fix this by resetting kthread_vid_cap to NULL on failure before jumping to the error path. Fixes: 5cebaac60974 ("media: video-i2c: add video-i2c driver") Cc: stable@vger.kernel.org Signed-off-by: Uday Khare Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/i2c/video-i2c.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/media/i2c/video-i2c.c +++ b/drivers/media/i2c/video-i2c.c @@ -522,8 +522,12 @@ static int start_streaming(struct vb2_qu data->kthread_vid_cap = kthread_run(video_i2c_thread_vid_cap, data, "%s-vid-cap", data->v4l2_dev.name); ret = PTR_ERR_OR_ZERO(data->kthread_vid_cap); - if (!ret) - return 0; + if (ret) { + data->kthread_vid_cap = NULL; + goto error_rpm_put; + } + + return 0; error_rpm_put: pm_runtime_put_autosuspend(dev);