summaryrefslogtreecommitdiff
path: root/drivers/media
AgeCommit message (Collapse)Author
40 hoursmedia: ipu6: Fix up missing IWYU issueMark Brown
In -next: /tmp/next/build/drivers/media/pci/intel/ipu6/ipu7-fw-isys.c:229:3: error: call to undeclared function 'clflush_cache_range'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] 229 | clflush_cache_range(cpu_mapped_buf, size); | ^ Signed-off-by: Mark Brown <broonie@kernel.org>
40 hoursMerge branch 'headers' of git://git.infradead.org/users/willy/pagecache.gitMark Brown
# Conflicts: # net/ceph/osd_client.c
43 hoursMerge branch 'next' of git://linuxtv.org/media-ci/media-pending.gitMark Brown
43 hoursMerge branch 'i2c/i2c-next' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git
43 hoursMerge branch 'mm-nonmm-unstable' of ↵Mark Brown
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
43 hoursMerge branch 'fixes' of git://linuxtv.org/media-ci/media-pending.gitMark Brown
2 daysdrivers/media/v4l2-core/v4l2-vp9.c: reduce inliningAndrew Morton
csky allmodconfig, gcc-15.2.0: drivers/media/v4l2-core/v4l2-vp9.c: In function 'v4l2_vp9_adapt_noncoef_probs': drivers/media/v4l2-core/v4l2-vp9.c:1834:1: error: the frame size of 1436 bytes is larger than 1280 bytes [-Werror=frame-larger-than=] The amount of inlining in there is simply nuts. This patch semi-randomly uninlines various things and fixes the above. Ad the .text size reduction is tremendous: ts:/usr/src/25> size drivers/media/v4l2-core/v4l2-vp9.o text data bss dec hex filename 22450 36 0 22486 57d6 drivers/media/v4l2-core/v4l2-vp9.o-before 16144 36 0 16180 3f34 drivers/media/v4l2-core/v4l2-vp9.o-after Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Cc: Mauro Carvalho Chehab <mchehab@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
3 daysmedia: vicodec: zero-initialize stateful decoder heap buffersJunrui Luo
The stateful decoder leaks uninitialized kernel heap memory to userspace. A process that can open the decoder video node gets it back in the CAPTURE buffers it dequeues. The reference frame and the compressed frame buffer are allocated with kvmalloc() in vicodec_start_streaming(), and the decoder can read them before they have been written. The first frame is allowed to be a P-frame, in which case it is decoded against a reference frame that was never produced, and the padding rows below the visible area are never written for any frame. Use kvzalloc() for both allocations. Fixes: 256bf813ba39 ("media: vicodec: add the virtual codec driver") Reported-by: Yuhao Jiang <danisjiang@gmail.com> Assisted-by: Claude:claude-opus-5 Cc: stable@vger.kernel.org Signed-off-by: Junrui Luo <moonafterrain@outlook.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: vivid: cancel svid ctrl work on releaseFan Wu
vivid_dev_release() cancels update_hdmi_ctrl_work but not its sibling update_svid_ctrl_work, which vivid_vid_cap_s_ctrl() queues on update_svid_ctrls_workqueue when a VIVID_CID_SVID_IS_CONNECTED_TO_OUTPUT control is changed. The two work items were added together, but only one of them is cancelled on release. If the svid work is still pending or running when the last v4l2_device reference is dropped, update_svid_ctrls_work_handler() runs after kfree(dev): the handler iterates the global vivid_devs[] array and calls v4l2_ctrl_modify_range() on every vivid_dev instance, including this one after it has been freed. Add the missing cancel_work_sync() next to the hdmi sibling, before vivid_free_controls() releases the control handlers the work uses. This issue was found by an in-house static analysis tool. Fixes: d7c969f37515 ("media: vivid: Add 'Is Connected To' menu controls") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5.6 Co-developed-by: Song Li <songl@zju.edu.cn> Signed-off-by: Song Li <songl@zju.edu.cn> Signed-off-by: Fan Wu <fanwu01@zju.edu.cn> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: vim2m: give vim2m a proper control ID rangeHans Verkuil
The vim2m driver has two driver-specific controls, but the control IDs were never reserved in v4l2-control.h. While these control IDs clash with the range reserved for the old meye driver, since that meye driver has been removed from the kernel quite a long time ago we just officially claim that range for the vim2m driver. Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Reported-by: Nicolas Dufresne <nicolas@ndufresne.ca> Closes: https://lore.kernel.org/linux-media/71a3fa9710cf1afbb80ebe850878557c3e95a1b2.camel@ndufresne.ca/ Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
3 daysmedia: cx231xx: preserve I2C transfer lengthJuan Perdomo
The I2C core stores message lengths in u16, but cx231xx truncates them to u8 when populating cx231xx_i2c_xfer_data. A 0x700-byte read therefore becomes a zero-length request. USB treats zero-length control transfers as OUT regardless of bRequestType, so the IN control pipe trips the usb_submit_urb() direction warning. Use u16 for buf_size, matching both i2c_msg.len and VENDOR_REQUEST_IN.wLength. Oversized transfers then reach the existing URB_MAX_CTRL_SIZE check and return -EINVAL. Fixes: e0d3bafd0258 ("V4L/DVB (10954): Add cx231xx USB driver") Cc: stable@kernel.org Reported-by: syzbot+ddccc0c0dbc0a38ffccb@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=ddccc0c0dbc0a38ffccb Tested-by: syzbot+ddccc0c0dbc0a38ffccb@syzkaller.appspotmail.com Signed-off-by: Juan Perdomo <jcperdomo100@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: synopsys: hdmirx: Remove redundant dev_err_probe()Amin Gattout
The devm_request_threaded_irq() function now automatically logs detailed error messages on failure. This eliminates the need for driver-specific dev_err_probe() calls that print generic messages. Signed-off-by: Amin Gattout <amin.gattout@gmail.com> Reviewed-by: Igor Paunovic <royalnet026@gmail.com> Acked-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: vivid: round the height down to the vertical subsampling factorMaxim Skokov
syzbot reports a vmalloc out-of-bounds write in the test pattern generator: BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_pattern drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2617 [inline] BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_buffer+0x2063/0x4160 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2705 Write of size 720 at addr ffffc900038f9d50 by task vivid-000-vid-c/6017 The reproducer requests a 720x49 NV12 capture format, i.e. an odd height for a format whose chroma plane is vertically subsampled. The buffer size is derived from the height by a truncating division: sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p]; For a single buffer holding both planes tpg_g_line_width() returns 720 + 720 / 2 = 1080, so 1080 * 49 = 52920 bytes get allocated. tpg_fill_plane_buffer() however emits one chroma line for every two luma lines, i.e. DIV_ROUND_UP(49, 2) = 25 lines, and thus needs 49 * 720 + 25 * 720 = 53280 bytes. The memcpy() of the last chroma line runs 360 bytes past the end of the buffer. An odd height is not meaningful for a 4:2:0 format in the first place, since the chroma plane would have to hold half a line. Rather than fixing up each of the ~10 sites that divide the height by vdownsampling[], round the height down to a multiple of the vertical subsampling factor where it enters the driver. Adjusting the format is what TRY_FMT/S_FMT are for, and it keeps every later division exact. Formats without vertical subsampling are unaffected and keep accepting odd heights. Tested with the syzbot reproducer, which no longer triggers the splat, and by streaming NV12, NV21, YUV420, YVU420 and YUYV at heights 47, 48, 49, 51, 480, 481 and 1081. v4l2-compliance gives identical results before and after (48 of 50 succeeded on the vivid device in both cases; the two failures are pre-existing and unrelated). Fixes: ddcaee9dd4c0 ("[media] vivid: add support for single buffer planar formats") Cc: stable@kernel.org Reported-by: syzbot+cb43e758a4dc84dd467f@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=cb43e758a4dc84dd467f Signed-off-by: Maxim Skokov <skokovmaksimevg@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: dvb-usb-v2/mxl111sf-i2c: fix typo "initilize" in commentsHemanth Selam
Correct "initilize" to "initialize", reported by scripts/checkpatch.pl using the misspelling list in scripts/spelling.txt. Only touches comments, no code changes. Assisted-by: Cursor:claude-opus-5 Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: saa7164: fix repeated word in log messageHemanth Selam
Drop the word written twice, reported by checkpatch.pl as a possible repeated word. Only the message text changes, no code changes. Assisted-by: Cursor:claude-opus-5 Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: fix repeated words in commentsHemanth Selam
Drop words accidentally written twice, reported by checkpatch.pl as a possible repeated word. Only touches comments, no code changes. Assisted-by: Cursor:claude-opus-5 Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: fix typos in commentsHemanth Selam
Fix typos in comments, reported by scripts/checkpatch.pl using the misspelling list in scripts/spelling.txt. Only touches comments, no code changes. Assisted-by: Cursor:claude-opus-5 Signed-off-by: Hemanth Selam <hemanth.selam@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: cx25840: return -EOPNOTSUPP instead of WARN_ON in cx25840_initMuhammad Haris Awan
cx25840_init() implements generic mode video output configuration only for cx2584x chips. For other chips, it triggers a WARN_ON(1) and returns 0, falsely indicating successful initialization while leaving the chip unconfigured and marking generic_mode as true. Using WARN_ON() for unsupported hardware variants is discouraged as it triggers kernel warnings and syzbot alerts on faulty or unsupported devices. Return -EOPNOTSUPP early if the chip is not a cx2584x variant so callers (such as cxusb_medion_register_analog_subdevs()) can handle the error cleanly. Reported-by: syzbot+9123948aef13fe92d706@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=9123948aef13fe92d706 Tested-by: syzbot+9123948aef13fe92d706@syzkaller.appspotmail.com Signed-off-by: Muhammad Haris Awan <m.harisawan@icloud.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> [hverkuil: fixed the mangled patch]
3 daysmedia: nuvoton: npcm-video: Use devm_of_reserved_mem_device_init()Mukesh Ojha
Switch to devm_of_reserved_mem_device_init() so the reserved memory region is released automatically on probe failure or device removal. Remove the four explicit of_reserved_mem_device_release() calls and collapse the now-empty err_release_mem label into err_free. Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: aspeed: Use devm_of_reserved_mem_device_init()Mukesh Ojha
Switch to devm_of_reserved_mem_device_init() so the reserved memory region is released automatically on probe failure or device removal. Remove the three explicit of_reserved_mem_device_release() calls and rename the error label from err_release_reserved_mem to err_unprepare_vclk to reflect that it now only unwinds clock state. Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
3 daysmedia: synopsys: hdmirx: Use devm_of_reserved_mem_device_init()Mukesh Ojha
Replace the hand-rolled devm_hdmirx_of_reserved_mem_device_release() devres action with devm_of_reserved_mem_device_init(), which handles the cleanup automatically. This removes both the wrapper function and the devm_add_action_or_reset() call. Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysMerge branch 'i2c/i2c' into i2c/i2c-nextAndi Shyti
4 daysmedia: i2c: isl7998x: Inline i2c_check_functionality() checkThorsten Blum
Inline the i2c_check_functionality() check, since the function returns a boolean status rather than an error code. Reviewed-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Thorsten Blum <blum@kernel.org> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Link: https://patch.msgid.link/20260909082053.410739-4-blum@kernel.org
4 daysmedia: cec: meson: ao-cec-g12a: Make sure clk_init_data is fully initializedGeert Uytterhoeven
The clk_init_data structure contains several mutually-exclusive members for different methods to specify the possible parents of a clock, prompting drivers to initialize only the members they need. However, not initializing all members may cause subtle issues, which are only exposed when CONFIG_INIT_STACK_ALL_PATTERN or CONFIG_INIT_STACK_NONE is enabled. Make sure all members are fully initialized, to avoid such bugs, and to prevent future breakage when converting drivers to a different method for specifying the parents. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: require two-byte Cypress type 04 recordsPengpeng Hou
Both Cypress Intel HEX parsers read two address bytes from type 04 records. Generic record framing permits any record length, so a short record can make the parser consume the checksum or bytes beyond the firmware record. A longer record also violates the Intel HEX type 04 layout. Require the type 04 payload length to be exactly two bytes in both implementations. Fixes: 79a63c60a6a2 ("[media] media: move dvb-usb-v2/cypress_firmware.c to media/common") Fixes: 776338e121b9 ("[PATCH] dvb: Add generalized dvb-usb driver") Cc: stable@kernel.org Assisted-by: Codex:gpt-5 Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: v4l2-ctrls: default HEVC SPS chroma format to 4:2:0Tharit Tangkijwanichakul
The default value of a compound control is zero initialized when no explicit default is provided. For V4L2_CTRL_TYPE_HEVC_SPS this results in chroma_format_idc being set to 0, which represents monochrome video. Most stateless HEVC decoders do not support monochrome video. In particular, the VDPU38x variant of rkvdec fails v4l2-compliance in two tests related to V4L2_CID_STATELESS_HEVC_SPS. The Control ioctls test reads the control with GET_EXT_CTRLS and writes the same value back; TRY_EXT_CTRLS then returns -EINVAL because the VDPU38x rkvdec_hevc_validate_sps() rejects sps->chroma_format_idc == 0. v4l2-compliance 1.33.0-5491, 64 bits, 64-bit time_t v4l2-compliance SHA: b32589c51481 2026-07-16 08:51:38 Control ioctls: fail: v4l2-test-controls.cpp(942): try_ext_ctrls returned an error (22) test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL Buffer ioctls: fail: v4l2-test-buffers.cpp(3102): node->streamon(q.g_type()) fail: v4l2-test-buffers.cpp(3157): testBlockingDQBuf(node, m2m_q) test blocking wait: FAIL Set the common HEVC SPS compound control default to chroma_format_idc = 1, corresponding to 4:2:0. Fixes: c9a59dc2acc7 ("media: rkvdec: Add HEVC support for the VDPU381 variant") Cc: stable@kernel.org Signed-off-by: Tharit Tangkijwanichakul <tharitt97@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: i2c: add driver for ITE IT6625/IT6626Hermes Wu
Add a V4L2 subdevice driver for the ITE IT6625/IT6626 HDMI-to-MIPI CSI-2 bridge chips. IT6625 accepts an HDMI 2.0 input and IT6626 an HDMI 2.1 input, converting it to a D-PHY (or C/D-PHY on IT6626) MIPI CSI-2 output. The bridge is configured over I2C, exposes an HDMI CEC adapter, and supports EDID read/write, DV timings detection/configuration, and HPD control via the standard V4L2 subdevice pad and video ops. Signed-off-by: Hermes Wu <Hermes.wu@ite.com.tw> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> [hverkuil: change it6625_v4l2_sd_ctrl_update to a void function]
4 daysmedia: ti: cal: Deprecate non-MC API usageLaurent Pinchart
The MC API was introduced in the CAL driver more than five years ago in commit 38e89e790fe2 ("media: ti-vpe: cal: Implement media controller centric API") as a disabled by default option. Five years later, it's time to give users another nudge to move to the MC API. Deprecate non-MC API usage by printing a warning at probe time, and defaulting to the MC API. The legacy API can still be selected through the mc_api module parameter. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Reviewed-by: Yemike Abhilash Chandra <y-abhilashchandra@ti.com> Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: synopsys: hdmirx: add HDMI audio capture supportIgor Paunovic
The Synopsys DesignWare HDMI RX controller extracts the audio stream embedded in the incoming HDMI signal and feeds it to an on-SoC I2S controller. Expose it as an ALSA capture device by registering the generic hdmi-codec as a child of the controller, so that a simple-audio-card in the device tree can bind the HDMI RX audio DAI. The sample rate is recovered from the ACR N/CTS values together with the measured TMDS character rate. A periodic worker keeps the local audio reference clock locked to the source by nudging it in small ppm steps to hold the audio FIFO fill level near its target, which avoids FIFO under/overflow and the resulting dropped samples. Across system suspend the worker is stopped before the controller clocks are gated. Resume fully resets the controller, wiping the audio configuration, so when a capture stream is active it re-programs the audio path from the last known sample rate and re-arms the worker, whose rate change and FIFO error paths resynchronize once the source delivers audio again. Signed-off-by: Igor Paunovic <royalnet026@gmail.com> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: nuvoton: npcm-video: quiesce VCD IRQ before teardownFan Wu
The VCD IRQ is devm-requested, but npcm_video_remove() frees the video object before devres releases that IRQ. The threaded handler dereferences video->vcd_regmap before checking VIDEO_STREAMING, so an interrupt in that interval can access freed memory. Request the IRQ with IRQF_NO_AUTOEN. Enable it after starting capture and setting VIDEO_STREAMING, and disable it first in stop_streaming(). disable_irq() waits for an in-flight threaded handler to finish, after which stop_streaming() can mask and reset the VCD without a handler re-enabling it. Use vb2_video_unregister_device() during remove. It releases the vb2 queue and calls stop_streaming() for an active stream, ensuring that the IRQ is disabled before the video object is freed. Do not release the queue separately. If streaming is never started, IRQF_NO_AUTOEN keeps the IRQ disabled until devres releases it. This issue was found by an in-house static analysis tool. Fixes: 46c15a4ff1f4 ("media: nuvoton: Add driver for NPCM video capture and encoding engine") Cc: stable@kernel.org Assisted-by: Codex:gpt-5.6 Signed-off-by: Fan Wu <fanwu01@zju.edu.cn> Tested-by: Marvin Lin <kflin@nuvoton.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: synopsys: hdmirx: use request_any_context_irq() for 5V detection IRQAlexander Shiyan
Replace devm_request_irq() with devm_request_any_context_irq() for the 5V detection interrupt handler. This allows the kernel to choose the appropriate execution context (hardirq or threaded) depending on the underlying interrupt controller. On some platforms, the interrupt may be nested or require a threaded handler, and using the fixed hardirq version can cause probe failures. Switching to the more flexible function improves driver portability without affecting functionality. Fixes: 7b59b132ad43 ("media: platform: synopsys: Add support for HDMI input driver") Cc: stable@kernel.org Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: stv0900: bound DiSEqC reply length to msg[] sizeGreg Kroah-Hartman
The FIFO_BYTENBR field is 4 bits (mask 0x0f), giving a length of 0..15 but reply->msg is __u8[4] in struct dvb_diseqc_slave_reply. A faulty or malicious device reporting more than 4 bytes will the array and clobber the stack. The stb0899, tda10071, and s5h1420 drivers all properly bound the FIFO count against sizeof(reply->msg) before the read loop, so do the same thing in this driver. Fixes: 99277b3824e4 ("V4L/DVB (10803): Add core code for ST STV0900 dual demodulator.") Cc: stable@kernel.org Assisted-by: gregkh_clanker_t1000 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: stv090x: bound DiSEqC reply length to msg[] sizeGreg Kroah-Hartman
The FIFO_BYTENBR_FIELD register field is 4 bits wide, giving a length of 0..15, but reply->msg is __u8[4] in struct dvb_diseqc_slave_reply. A faulty or malicious DiSEqC slave (or i2c bus glitch) reporting more than 4 bytes will the array and clobber the stack. The stb0899, tda10071, and s5h1420 drivers all properly bound the FIFO count against sizeof(reply->msg) before the read loop, so do the same thing in this driver. Fixes: e415c689a884 ("V4L/DVB (11579): Initial go at TT S2-1600") Cc: stable@kernel.org Assisted-by: gregkh_clanker_t1000 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: adv7604: avoid negative array index in log_status when cp_read failsGreg Kroah-Hartman
cp_read() returns the negative errno from regmap_read() on I2C failure. adv76xx_log_status() shifts the result right by 4 and uses it directly to index csc_coeff_sel_rb[16] causing the right shift of a negative number to result in -1, reading a negative place in the array. Commit 8163419e3e05 ("media: adv7842: Avoid possible out-of-bounds array accesses in adv7842_cp_log_status()") fixed the identical pattern in the adv7842, so do the same thing here. Fixes: 54450f591c99 ("[media] adv7604: driver for the Analog Devices ADV7604 video decoder") Cc: stable@kernel.org Assisted-by: gregkh_clanker_t1000 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-csi2dc: fix async notifier leak on probe error pathCong Nguyen
csi2dc_of_parse() ends up calling csi2dc_prepare_notifier(), which registers the V4L2 async notifier with v4l2_async_nf_register(). The probe error label csi2dc_probe_cleanup_notifier is reached after csi2dc_of_parse() has already succeeded (e.g. when media entity init, csi2dc_power() or v4l2_async_register_subdev() fail), but it calls only v4l2_async_nf_cleanup() and never v4l2_async_nf_unregister(). The notifier therefore stays chained in the global notifier_list while the enclosing struct csi2dc_device is freed, leading to list corruption and a use-after-free when the list is next walked. Unregister the notifier before cleaning it up on the error path, matching the teardown already done in csi2dc_remove(). Fixes: 2de0b3c0f678 ("media: atmel: introduce microchip csi2dc driver") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4 Signed-off-by: Cong Nguyen <congnt264@gmail.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: stm32: csi: unregister async notifier on cleanupMyeonghun Pak
stm32_csi_parse_dt() registers the async notifier before probe finishes. If a later operation fails, the error path only cleans up the notifier's connections. It does not unregister the notifier, leaving its entry on the global notifier list after the devm-allocated csidev is freed. The remove path has the same problem. A later async operation can then walk the stale notifier entry and access freed memory. Unregister the notifier before cleaning up its resources on both paths. Fixes: dcb0f4c16be5 ("media: stm32: csi: addition of the STM32 CSI driver") Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: stm32: csi: correct remote pad retrievalAlain Volmat
The function media_entity_get_fwnode_pad is called in order to retrieve the remote pad, which is the source of the CSI. However this function is expecting the sensor endpoint fwnode and not sensor device fwnode as it is currently given. Correct this by properly relying on the notified matched fwnode data instead of the subdev entity fwnode. Cc: stable@kernel.org Fixes: dcb0f4c16be5 ("media: stm32: csi: addition of the STM32 CSI driver") Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: don't sleep in the clk .is_enabled callbackBalakrishnan Sambath
isc_clk_is_enabled() calls pm_runtime_resume_and_get() and pm_runtime_put_sync(), which can sleep and are not safe here, as .is_enabled must run in atomic context. clk_disable_unused() calls it so at boot, and CONFIG_DEBUG_ATOMIC_SLEEP reports a "sleeping function called from invalid context" BUG. Use the atomic-safe pm_runtime_get_if_active() and pm_runtime_put() instead. A suspended ISC has its clocks gated, so report the clock disabled when the device is not already active. Fixes: 01192aa1c5c2 ("media: atmel-isc: Enable the clocks during probe") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: fix WB offset and gain register field maskingBalakrishnan Sambath
ISC_WB_O_* and ISC_WB_G_* each pack two 13-bit fields. A negative offset sign-extends and corrupts the adjacent field. Add masks for the two fields and write them with FIELD_PREP(), which masks each value into its field, so sign extension can no longer bleed across. Fixes: 73c1a577b839 ("media: atmel: atmel-isc: reworked white balance feature") Cc: stable@vger.kernel.org Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: fix SBGGR10 Bayer patternBalakrishnan Sambath
SBGGR10 was mapped to ISC_BAY_CFG_RGRG instead of ISC_BAY_CFG_BGBG, causing red/blue channel swap. Fixes: 1e8f401474d6 ("media: atmel: atmel-isc: reworked driver and formats") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: fix PM runtime leak in AWB work handlerBalakrishnan Sambath
Early return when streaming stops skips pm_runtime_put_sync(), leaking the reference and preventing runtime suspend. Fixes: 314c96e5203d ("media: atmel: atmel-isc-base: use mutex to lock awb workq from streaming") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: fix ISC_PFG_CFG0_BPS macro name typoBalakrishnan Sambath
The BPS field macros for ISC_PFE_CFG0 were spelled ISC_PFG_CFG0_BPS_* (NINE, TEN, ELEVEN, TWELVE). The register is PFE, not PFG. Rename them to ISC_PFE_CFG0_BPS_* to match the register and the EIGHT and MASK macros. No functional change. Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: store the unshifted PFE_CFG0 BPS valueBalakrishnan Sambath
pfe_cfg0_bps held a pre-shifted BPS value (ISC_PFE_CFG0_BPS_EIGHT was 0x4 << 28) ORed straight into the register. The other format selectors like cfa_baycfg store the bare field value and position it at the write, so this one was inconsistent. Store the bare BPS value and apply it with FIELD_PREP() at the PFE_CFG0 write, and fix the pfe_cfg0_bps comment to match. No functional change. Suggested-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: do not touch WB registers when not streamingBalakrishnan Sambath
isc_s_awb_ctrl() called isc_update_awb_ctrls() unconditionally, writing the white balance registers even when the device is runtime suspended; on many ARM platforms accessing the unclocked registers is an external abort. The write was also done without awb_lock, racing isc_awb_work(), which holds it so the DMA done IRQ cannot latch a half-updated pipeline. Write the registers only while streaming and not stopping, under awb_lock, and update the profile there. The isc->stop check covers the window where isc_stop_streaming() has gated the clocks but vb2 still reports streaming. Otherwise the new values stay cached and isc_configure() programs them at the next stream start. Fixes: 4e52889f48fe ("media: atmel: atmel-isc-base: expose white balance as v4l2 controls") Cc: stable@vger.kernel.org Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: disable histogram and flush AWB work on teardownBalakrishnan Sambath
isc_stop_streaming() and the isc_start_streaming() error path dropped the runtime PM reference with the histogram still enabled. A HISDONE firing just before the stop, or a failed isc_update_profile() on the start path, can queue isc_awb_work(), which reads the histogram registers before taking its own PM reference and faults on the unclocked device. Disable the histogram, synchronize the IRQ and flush the work before the device is left unclocked. isc_configure() is the one enabling the histogram and then calling isc_update_profile(), so do the cleanup in its own failure path; isc_stop_streaming() does the same on teardown. synchronize_irq() must come before cancel_work_sync(), so an in-flight handler cannot re-queue awb_work after it is cancelled. Fixes: 93d4a26c3dab ("[media] atmel-isc: add the isc pipeline function") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: synchronize the IRQ before disabling clocks on stopBalakrishnan Sambath
isc_stop_streaming() masks the DMA interrupt and then drops the runtime PM reference, which disables the ISC clocks. microchip_isc_interrupt() may still be executing on another CPU at that point; it reads ISC_INTSR over regmap, and touching the unclocked registers triggers an external abort. Store the IRQ number at probe and call synchronize_irq() after masking the interrupt, before dropping the PM reference. Fixes: 106267444f12 ("[media] atmel-isc: add the Image Sensor Controller code") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: take a reference on the parsed endpointsBalakrishnan Sambath
for_each_endpoint_of_node() drops the reference on the current node as it advances. xisc_parse_dt() and isc_parse_dt() store the node in subdev_entity->epn and release it later with of_node_put(), but never took their own reference, so the stored pointer refers to an already-released node. This underflows the refcount and can use-after-free, reachable through the camera device tree overlay. Take a reference with of_node_get() when storing the node, and drop it in microchip_isc_subdev_cleanup() so the entities the bind loop never reaches on an early exit do not leak it. Fixes: c9aa973884a1 ("media: atmel: atmel-isc: add microchip-xisc driver") Fixes: d6701f13bd07 ("media: atmel: Use v4l2_async_notifier_add_fwnode_remote_subdev") Cc: stable@vger.kernel.org Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: microchip-isc: fix awb_mutex and lock lifecycleBalakrishnan Sambath
isc->lock and awb_mutex were initialised in isc_async_complete() and destroyed in isc_async_unbind(), tying their lifetime to the subdev bind/unbind cycle instead of the device: - isc_async_unbind() destroyed awb_mutex before cancel_work_sync(), which takes it; - a failed .complete() left them initialised, and isc->lock was destroyed only on the .complete() error path, so the normal unbind path leaked it; - a rebind runs .complete() again and reinitialises a live mutex. Initialise both with devm_mutex_init() at probe so they live for the whole device lifetime and are freed at remove, and drop the init and destroy from the .complete()/.unbind() callbacks. isc_async_complete_err then only returned ret, so drop the label and return directly at each error site. Fixes: 314c96e5203d ("media: atmel: atmel-isc-base: use mutex to lock awb workq from streaming") Cc: stable@vger.kernel.org Reviewed-by: Eugen Hristev <ehristev@kernel.org> Signed-off-by: Balakrishnan Sambath <balakrishnan.s@microchip.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: stm32: dcmipp: instantiate & link stm32mp25 subdevsAlain Volmat
Add topology of the two pixel pipes (main & aux) of the stm32mp25. Do not make the link from dcmipp_input immutable and enabled by default since not all pipes are always used together so when a pipeline is not being used its link should be disconnected to allow proper pipeline check. Not doing this would most probably lead to pipeline start failure due to incompatible pads configurations on the unused pipe. Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
4 daysmedia: stm32: dcmipp: rename bytecap into captureAlain Volmat
Since the bytecap video driver is now handling all capture (byte & pixel), rename the file and structs *into capture. This is done by: - renaming of dcmipp-bytecap.c into dcmipp-capture.c - replace of dcmipp_bytecap strings into dcmipp_capture Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>