media: mc: mark the media devnode as registered from the, start
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 23 Feb 2024 08:46:19 +0000 (09:46 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 22 Apr 2024 09:41:04 +0000 (11:41 +0200)
commit4bc60736154bc9e0e39d3b88918f5d3762ebe5e0
tree88a3a09a5a3427ab20bdaa64759d134a42cc1e5a
parente671a83f96ae130a2f9b111955eceb74868c9f87
media: mc: mark the media devnode as registered from the, start

First the media device node was created, and if successful it was
marked as 'registered'. This leaves a small race condition where
an application can open the device node and get an error back
because the 'registered' flag was not yet set.

Change the order: first set the 'registered' flag, then actually
register the media device node. If that fails, then clear the flag.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Fixes: cf4b9211b568 ("[media] media: Media device node support")
Cc: stable@vger.kernel.org
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
drivers/media/mc/mc-devnode.c