mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alper Ak <alperyasinak1@gmail.com>
To: Nas Chung <nas.chung@chipsnmedia.com>,
	Jackson Lee <jackson.lee@chipsnmedia.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Nicolas Dufresne <nicolas.dufresne@collabora.com>,
	Hans Verkuil <hverkuil+cisco@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Alper Ak <alperyasinak1@gmail.com>
Subject: [PATCH] media: chips-media: wave5: Fix possible ERR_PTR deference
Date: Sat,  7 Feb 2026 13:32:24 +0300	[thread overview]
Message-ID: <20260207103224.609938-1-alperyasinak1@gmail.com> (raw)

The kthread_run() function returns either a valid task_struct pointer
or ERR_PTR() on failure. The return value was not checked and in the
error cleanup path, the code verifies if dev->irq_thread is non NULL
before calling kthread_stop(). Since ERR_PTR() values are non NULL,
this would result in passing an error pointer to kthread_stop(),
causing a kernel panic.

Add proper IS_ERR() check after kthread_run(), log the error, set
dev->irq_thread to NULL and fail the probe to prevent the driver
from operating in a broken state.

Fixes: e66ff2b08e4e ("media: chips-media: wave5: Fix Null reference while testing fluster")
Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
 drivers/media/platform/chips-media/wave5/wave5-vpu.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/platform/chips-media/wave5/wave5-vpu.c b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
index 76d57c6b636a..bebe2bd6893b 100644
--- a/drivers/media/platform/chips-media/wave5/wave5-vpu.c
+++ b/drivers/media/platform/chips-media/wave5/wave5-vpu.c
@@ -340,6 +340,12 @@ static int wave5_vpu_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "failed to get irq resource, falling back to polling\n");
 		sema_init(&dev->irq_sem, 1);
 		dev->irq_thread = kthread_run(irq_thread, dev, "irq thread");
+		if (IS_ERR(dev->irq_thread)) {
+			dev_err(&pdev->dev, "failed to create vpu irq thread\n");
+			ret = PTR_ERR(dev->irq_thread);
+			dev->irq_thread = NULL;
+			goto err_vdi_release;
+		}
 		hrtimer_setup(&dev->hrtimer, &wave5_vpu_timer_callback, CLOCK_MONOTONIC,
 			      HRTIMER_MODE_REL_PINNED);
 		dev->worker = kthread_run_worker(0, "vpu_irq_thread");
-- 
2.43.0


             reply	other threads:[~2026-02-07 10:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-07 10:32 Alper Ak [this message]
2026-02-11  9:12 ` Nas Chung
     [not found]   ` <CAGpma=5ONpUwnOStE+cLpJcqrb-=ZYT4krx=whgeAup1ACERQg@mail.gmail.com>
2026-02-13  5:38     ` Nas Chung
2026-02-13 11:38 ` Markus Elfring
2026-03-06  6:32   ` Alper Ak
2026-03-06  6:54     ` Markus Elfring
2026-03-06 13:50     ` [PATCH] " Nicolas Dufresne
2026-10-20 19:16       ` Nicolas Dufresne
2026-10-21  9:04         ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260207103224.609938-1-alperyasinak1@gmail.com \
    --to=alperyasinak1@gmail.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=jackson.lee@chipsnmedia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nas.chung@chipsnmedia.com \
    --cc=nicolas.dufresne@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®