mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: laurent.pinchart@ideasonboard.com
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: mchehab@kernel.org, sakari.ailus@linux.intel.com,
	hverkuil@kernel.org, linux-media@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Deepanshu Kartikey <kartikey406@gmail.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH 2/2] media: mc: fix race in media_device_unregister_entity()
Date: Mon, 02 Nov 2026 17:13:32 +0200	[thread overview]
Message-ID: <310714a97367e59064d1b2d5c0665c4f@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20261102141439.13505-3-kartikey406@gmail.com>

Hello,

This is an automated reply.

You have sent a patch or bug report that appears to have been generated
by an LLM. The commit message, code and/or problem description show
little to no real understanding of the issue and changes being proposed.

Such patches or reports require a large amount of work to handle. They
rely on maintainers to propose - and often even implement - a proper
design. The probability that the author will learn from the experience
to improve their future contributions is close to zero.

As a result, to make good use of maintainer time and keep the kernel
development process sustainable, your contribution has been rejected.

If you believe the change you proposed is important, take time to study
the problem, learn, and develop a solution without AI assistance.
Answering this e-mail or generating a new version of a patch by feeding
this reply to an LLM will only result in your e-mails being ignored.

Please note that if your patch attempted to address an important
problem, maintainers or other contributors can submit and merge a
similar or entirely different fix without crediting you.

Your contributions to the Linux kernel will be welcome if you genuinely
desire to invest your time and learn.

Thank you,

Laurent's mail bot

On Mon, 02 Nov 2026 19:44:39 +0530, Deepanshu Kartikey <kartikey406@gmail.com> wrote:
> media_device_unregister_entity() checks entity->graph_obj.mdev for NULL
> before taking mdev->graph_mutex, but does not check again afterwards.
> If media_device_unregister() runs concurrently (for example on USB
> disconnect), it unregisters every entity and clears graph_obj.mdev while
> this function waits for the mutex. The waiter then calls
> __media_device_unregister_entity() with a NULL mdev and faults in
> ida_free(&mdev->entity_internal_idx, ...):
> 
>   Oops: general protection fault, KASAN: null-ptr-deref in range
>   [0x00000000000000c8-0x00000000000000cf]
>    ida_free
>    __media_device_unregister_entity
>    media_device_unregister_entity
>    v4l2_device_release
>    v4l2_open
> 
> Re-check graph_obj.mdev under the lock and skip the unregister if the
> entity is already gone.
> 
> Found while testing the fix for the syzbot report at
> https://syzkaller.appspot.com/bug?extid=54648a6c1187a7ef46a6
> 
> Fixes: e2c91d4d78ee ("[media] media-device: get rid of the spinlock")
> Cc: stable@vger.kernel.org
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
>  drivers/media/mc/mc-device.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
> index f8ea7cfe10b2..039ef7d04ac7 100644
> --- a/drivers/media/mc/mc-device.c
> +++ b/drivers/media/mc/mc-device.c
> @@ -674,7 +674,8 @@ void media_device_unregister_entity(struct media_entity *entity)
>  		return;
>  
>  	mutex_lock(&mdev->graph_mutex);
> -	__media_device_unregister_entity(entity);
> +	if (entity->graph_obj.mdev)
> +		__media_device_unregister_entity(entity);
>  	mutex_unlock(&mdev->graph_mutex);
>  }
>  EXPORT_SYMBOL_GPL(media_device_unregister_entity);

      reply	other threads:[~2026-11-02 15:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 14:14 [PATCH 0/2] media: fix em28xx v4l2 init failure refcount underflow and a media core unregister race Deepanshu Kartikey
2026-11-02 14:14 ` [PATCH 1/2] media: em28xx: clear dev->v4l2 on v4l2 init failure Deepanshu Kartikey
2026-11-02 14:14 ` [PATCH 2/2] media: mc: fix race in media_device_unregister_entity() Deepanshu Kartikey
2026-11-02 15:13   ` laurent.pinchart [this message]

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=310714a97367e59064d1b2d5c0665c4f@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@kernel.org \
    --cc=kartikey406@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@vger.kernel.org \
    /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®