1. 29 Nov, 2021 10 commits
  2. 22 Nov, 2021 15 commits
  3. 19 Nov, 2021 15 commits
    • Sudip Mukherjee's avatar
      media: sp887x: drop unneeded assignment · e594cda5
      Sudip Mukherjee authored
      The pointer 'mem' was initialized to 'fw->data' but immediately after
      that it was assigned 'fw->data + 10'. Lets remove the extra assignement
      and initialize the pointer to the address its going to use.
      
      Link: https://lore.kernel.org/linux-media/20210416235336.1552102-1-sudipm.mukherjee@gmail.com
      
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e594cda5
    • Lukas Middendorf's avatar
      media: media si2168: fully initialize si2168 on resume only when necessary · 51c2664a
      Lukas Middendorf authored
      At connection time (or boot) in si2168_probe(), the firmware is not
      loaded to the device and the device is not fully activated. It is
      not useful or sensible to do this full initialization on resume in
      case it has not been previously initialized and is expected to be
      in this initialized state.
      Calling si2168_init() and therefore reading the firmware file for
      the first time during resume leads to problems and should be avoided.
      It is however safe to read the firmware file once it has already been
      read outside of a suspend/resume situation.
      
      Add a staus flag 'initialized' to store whether si2168_init() has
      successfully been called. If initialization fails (e.g. due to missing
      firmware file), the flag is not set.
      Register a separate si2168_resume callback which only calls
      si2168_init() once the 'initialized' flag has been set and it is safe
      to load the firmware at resume.
      The first call to si2168_init() will now always happen when the device
      is actually used for the first time and never during resume.
      This avoids the unsafe firmware file reading and should also speed up
      resume by skipping unnecessary device initialization.
      
      Link: https://lore.kernel.org/linux-media/20210418001204.7453-3-kernel@tuxforce.de
      
      [mchehab: fix several Coding Style issues]
      Cc: Antti Palosaari <crope@iki.fi>
      Signed-off-by: default avatarLukas Middendorf <kernel@tuxforce.de>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      51c2664a
    • Lukas Middendorf's avatar
      media: si2168: drop support for old firmware file name for si2168 B40 · 40ae6eff
      Lukas Middendorf authored
      The si2168 B40 firmware file name has been changed in or before 2014.
      During initialization, the new file name is preferred, but the old file
      name is used as a fallback when request_firmware with the new file name
      fails. Once reading the old file name has been attempted, only this name
      will be used on further firmware loading attempts. During resume,
      firmware reading with the new file name can (and likely will) fail even
      when it actually exists. So this permanent switch to the fallback
      firmware name happens even when not desired.
      
      Any system using a recent kernel version can be expected to have the
      firmware under the new name. The major distributions are either using
      the dvb firmware collection from LibreELEC, which has the new firmware
      file name, or do not package the firmware file but have documentation
      pointing towards a manual installation of the firmware file under the
      new name. If the firmware is available under the old name, it is
      severely outdated. If the switch to the old file name is performed,
      further firmware loading will either permanently fail (if it is not
      available) or an outdated firmware version will be used.
      
      Drop support for the fallback firmware file name and fail directly if
      the firmware is not available under its current name. On following
      attempts, the firmware read will then be retried with the correct
      current name instead of the old name.
      
      As reasoned above, there should be no negative effects of this change,
      while simplifying code (the B40 variant will be handled identical
      compared to the other variants of the si2168) and at the same time
      fixing possible problems if firmware loading fails on resume.
      
      Link: https://lore.kernel.org/linux-media/20210418161544.58858-1-kernel@tuxforce.deSigned-off-by: default avatarLukas Middendorf <kernel@tuxforce.de>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      40ae6eff
    • Mauro Carvalho Chehab's avatar
      media: dib0700: Only touch one bit when start/stop an adapter · c50fdd15
      Mauro Carvalho Chehab authored
      Only touch the right bit to enable/disable an adapter channel,
      without touching the other adapter's one.
      
      Tested on Nova-TD.
      
      Link: https://lore.kernel.org/linux-media/4214942f248baddec9cfd2b4b2424993ac356a51.1632689033.git.mchehab+huawei@kernel.org
      
      Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Kuron <michael.kuron@gmail.com>, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, pb@linuxtv.org
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      c50fdd15
    • Mauro Carvalho Chehab's avatar
      media: dib0700: cleanup start/stop streaming logic · e08d8f0f
      Mauro Carvalho Chehab authored
      Having two different paths to start/stop streaming, depending
      weather the USB endpoints are 0x82/0x83 or not makes it more
      prune to errors.
      
      Unify the logic.
      
      Link: https://lore.kernel.org/linux-media/065a6fff925a42153671fa5202c81882ca12c59c.1632689033.git.mchehab+huawei@kernel.org
      
      Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, Mauro Carvalho Chehab <mchehab@kernel.org>, Michael Kuron <michael.kuron@gmail.com>, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, pb@linuxtv.org
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e08d8f0f
    • Michael Kuron's avatar
      media: dib0700: fix undefined behavior in tuner shutdown · f7b77ebe
      Michael Kuron authored
      This fixes a problem where closing the tuner would leave it in a state
      where it would not tune to any channel when reopened. This problem was
      discovered as part of https://github.com/hselasky/webcamd/issues/16.
      
      Since adap->id is 0 or 1, this bit-shift overflows, which is undefined
      behavior. The driver still worked in practice as the overflow would in
      most environments result in 0, which rendered the line a no-op. When
      running the driver as part of webcamd however, the overflow could lead
      to 0xff due to optimizations by the compiler, which would, in the end,
      improperly shut down the tuner.
      
      The bug is a regression introduced in the commit referenced below. The
      present patch causes identical behavior to before that commit for
      adap->id equal to 0 or 1. The driver does not contain support for
      dib0700 devices with more adapters, assuming such even exist.
      
      Tests have been performed with the Xbox One Digital TV Tuner on amd64.
      Not all dib0700 devices are expected to be affected by the regression;
      this code path is only taken by those with incorrect endpoint numbers.
      
      Link: https://lore.kernel.org/linux-media/1d2fc36d94ced6f67c7cc21dcc469d5e5bdd8201.1632689033.git.mchehab+huawei@kernel.org
      
      Cc: stable@vger.kernel.org
      Fixes: 7757ddda ("[media] DiB0700: add function to change I2C-speed")
      Signed-off-by: default avatarMichael Kuron <michael.kuron@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      f7b77ebe
    • Scott K Logan's avatar
      media: s5h1411.c: Fix a typo in the VSB SNR table · 41604200
      Scott K Logan authored
      This looks like a typo. By manipulating the antenna on a device while
      monitoring the reported SNR, I was able to see the unexpected jump.
      After applying this patch, the spike was no longer present.
      
      Link: https://lore.kernel.org/linux-media/20211003001805.735092-1-logans@cottsay.netSigned-off-by: default avatarScott K Logan <logans@cottsay.net>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      41604200
    • Colin Ian King's avatar
      media: drivers: cx24113: remove redundant variable r · 40f45ab7
      Colin Ian King authored
      Variable r is being assigned values but its value was never used,
      being overriden on its first usage. So, drop the initialization.
      
      Addresses-Coverity: ("Unused value")
      
      Link: https://lore.kernel.org/linux-media/20211014151235.62671-1-colin.king@canonical.com
      
      Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      40f45ab7
    • Colin Ian King's avatar
      media: dvb-frontends/stv0367: remove redundant variable ADCClk_Hz · 32f4797d
      Colin Ian King authored
      GIT_AUTHOR_NAME=Colin King
      GIT_AUTHOR_EMAIL=colin.king@canonical.com
      
      Variable ADCClk_Hz is being initialised with a variable that is never read
      and then re-assigned immediately afterwards. Clean up the code by removing
      it and just returning the return value from the call to stv0367cab_get_mclk
      
      Addresses-Coverity: ("Unused value")
      
      Link: https://lore.kernel.org/linux-media/20211014153253.63527-1-colin.king@canonical.com
      
      Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      32f4797d
    • zhaoxiao's avatar
      media: dib9000: Use min() instead of doing it manually · e59a9e50
      zhaoxiao authored
      Fix following coccicheck warning:
      drivers/media/dvb-frontends/dib9000.c:261:10-11: WARNING opportunity for min()
      drivers/media/dvb-frontends/dib9000.c:345:10-11: WARNING opportunity for min()
      
      Link: https://lore.kernel.org/linux-media/20211117030656.14984-1-zhaoxiao@uniontech.com
      
      Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, zhaoxiao <zhaoxiao@uniontech.com>
      Signed-off-by: default avatarzhaoxiao <zhaoxiao@uniontech.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e59a9e50
    • Lukas Middendorf's avatar
      media: media dvb_frontend: add suspend and resume callbacks to dvb_frontend_ops · 98a1ca29
      Lukas Middendorf authored
      While dvb_tuner_ops already has dedicated suspend and resume callbacks,
      dvb_frontend_ops currently does not have them. Add those callbacks and
      use them for suspend and resume. If they are not set, the old behavior
      of calling sleep or init is used.
      
      This allows dvb_frontend drivers to handle resume differently from init,
      and suspend differently from sleep. No change is required for drivers
      not needing this functionality.
      
      Link: https://lore.kernel.org/linux-media/20210418001204.7453-2-kernel@tuxforce.de
      
      Cc: Lukas Middendorf <kernel@tuxforce.de>, Antti Palosaari <crope@iki.fi>, Mauro Carvalho Chehab <mchehab@kernel.org>, Luis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarLukas Middendorf <kernel@tuxforce.de>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      98a1ca29
    • Zheyu Ma's avatar
      media: b2c2: Add missing check in flexcop_pci_isr: · b1320303
      Zheyu Ma authored
      A out-of-bounds bug can be triggered by an interrupt, the reason for
      this bug is the lack of checking of register values.
      
      In flexcop_pci_isr, the driver reads value from a register and uses it as
      a dma address. Finally, this address will be passed to the count parameter
      of find_next_packet. If this value is larger than the size of dma, the
      index of buffer will be out-of-bounds.
      
      Fix this by adding a check after reading the value of the register.
      
      The following KASAN report reveals it:
      
      BUG: KASAN: slab-out-of-bounds in find_next_packet
      drivers/media/dvb-core/dvb_demux.c:528 [inline]
      BUG: KASAN: slab-out-of-bounds in _dvb_dmx_swfilter
      drivers/media/dvb-core/dvb_demux.c:572 [inline]
      BUG: KASAN: slab-out-of-bounds in dvb_dmx_swfilter+0x3fa/0x420
      drivers/media/dvb-core/dvb_demux.c:603
      Read of size 1 at addr ffff8880608c00a0 by task swapper/2/0
      
      CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.19.177-gdba4159c14ef #25
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
      Call Trace:
       <IRQ>
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0xec/0x156 lib/dump_stack.c:118
       print_address_description+0x78/0x290 mm/kasan/report.c:256
       kasan_report_error mm/kasan/report.c:354 [inline]
       kasan_report+0x25b/0x380 mm/kasan/report.c:412
       __asan_report_load1_noabort+0x19/0x20 mm/kasan/report.c:430
       find_next_packet drivers/media/dvb-core/dvb_demux.c:528 [inline]
       _dvb_dmx_swfilter drivers/media/dvb-core/dvb_demux.c:572 [inline]
       dvb_dmx_swfilter+0x3fa/0x420 drivers/media/dvb-core/dvb_demux.c:603
       flexcop_pass_dmx_data+0x2e/0x40 drivers/media/common/b2c2/flexcop.c:167
       flexcop_pci_isr+0x3d1/0x5d0 drivers/media/pci/b2c2/flexcop-pci.c:212
       __handle_irq_event_percpu+0xfb/0x770 kernel/irq/handle.c:149
       handle_irq_event_percpu+0x79/0x150 kernel/irq/handle.c:189
       handle_irq_event+0xac/0x140 kernel/irq/handle.c:206
       handle_fasteoi_irq+0x232/0x5c0 kernel/irq/chip.c:725
       generic_handle_irq_desc include/linux/irqdesc.h:155 [inline]
       handle_irq+0x230/0x3a0 arch/x86/kernel/irq_64.c:87
       do_IRQ+0xa7/0x1e0 arch/x86/kernel/irq.c:247
       common_interrupt+0xf/0xf arch/x86/entry/entry_64.S:670
       </IRQ>
      RIP: 0010:native_safe_halt+0x28/0x30 arch/x86/include/asm/irqflags.h:61
      Code: 00 00 55 be 04 00 00 00 48 c7 c7 00 62 2f 8c 48 89 e5 e8 fb 31
      e8 f8 8b 05 75 4f 8e 03 85 c0 7e 07 0f 00 2d 8a 61 66 00 fb f4 <5d> c3
      90 90 90 90 90 90 0f 1f 44 00 00 55 48 89 e5 41 57 41 56 41
      RSP: 0018:ffff88806b71fcc8 EFLAGS: 00000246 ORIG_RAX: ffffffffffffffde
      RAX: 0000000000000000 RBX: ffffffff8bde44c8 RCX: ffffffff88a11285
      RDX: 0000000000000000 RSI: 0000000000000004 RDI: ffffffff8c2f6200
      RBP: ffff88806b71fcc8 R08: fffffbfff185ec40 R09: fffffbfff185ec40
      R10: 0000000000000001 R11: fffffbfff185ec40 R12: 0000000000000002
      R13: ffffffff8be9d6e0 R14: 0000000000000000 R15: 0000000000000000
       arch_safe_halt arch/x86/include/asm/paravirt.h:94 [inline]
       default_idle+0x6f/0x360 arch/x86/kernel/process.c:557
       arch_cpu_idle+0xf/0x20 arch/x86/kernel/process.c:548
       default_idle_call+0x3b/0x60 kernel/sched/idle.c:93
       cpuidle_idle_call kernel/sched/idle.c:153 [inline]
       do_idle+0x2ab/0x3c0 kernel/sched/idle.c:263
       cpu_startup_entry+0xcb/0xe0 kernel/sched/idle.c:369
       start_secondary+0x3b8/0x4e0 arch/x86/kernel/smpboot.c:271
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243
      
      Allocated by task 1:
       save_stack+0x43/0xd0 mm/kasan/kasan.c:448
       set_track mm/kasan/kasan.c:460 [inline]
       kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:553
       kasan_slab_alloc+0x11/0x20 mm/kasan/kasan.c:490
       slab_post_alloc_hook mm/slab.h:445 [inline]
       slab_alloc_node mm/slub.c:2741 [inline]
       slab_alloc mm/slub.c:2749 [inline]
       kmem_cache_alloc+0xeb/0x280 mm/slub.c:2754
       kmem_cache_zalloc include/linux/slab.h:699 [inline]
       __kernfs_new_node+0xe2/0x6f0 fs/kernfs/dir.c:633
       kernfs_new_node+0x9a/0x120 fs/kernfs/dir.c:693
       __kernfs_create_file+0x5f/0x340 fs/kernfs/file.c:992
       sysfs_add_file_mode_ns+0x22a/0x4e0 fs/sysfs/file.c:306
       create_files fs/sysfs/group.c:63 [inline]
       internal_create_group+0x34e/0xc30 fs/sysfs/group.c:147
       sysfs_create_group fs/sysfs/group.c:173 [inline]
       sysfs_create_groups+0x9c/0x140 fs/sysfs/group.c:200
       driver_add_groups+0x3e/0x50 drivers/base/driver.c:129
       bus_add_driver+0x3a5/0x790 drivers/base/bus.c:684
       driver_register+0x1cd/0x410 drivers/base/driver.c:170
       __pci_register_driver+0x197/0x200 drivers/pci/pci-driver.c:1411
       cx88_audio_pci_driver_init+0x23/0x25 drivers/media/pci/cx88/cx88-alsa.c:
       1017
       do_one_initcall+0xe0/0x610 init/main.c:884
       do_initcall_level init/main.c:952 [inline]
       do_initcalls init/main.c:960 [inline]
       do_basic_setup init/main.c:978 [inline]
       kernel_init_freeable+0x4d0/0x592 init/main.c:1145
       kernel_init+0x18/0x190 init/main.c:1062
       ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415
      
      Freed by task 0:
      (stack is not available)
      
      The buggy address belongs to the object at ffff8880608c0000
       which belongs to the cache kernfs_node_cache of size 160
      The buggy address is located 0 bytes to the right of
       160-byte region [ffff8880608c0000, ffff8880608c00a0)
      The buggy address belongs to the page:
      page:ffffea0001823000 count:1 mapcount:0 mapping:ffff88806bed1e00
      index:0x0 compound_mapcount: 0
      flags: 0x100000000008100(slab|head)
      raw: 0100000000008100 dead000000000100 dead000000000200 ffff88806bed1e00
      raw: 0000000000000000 0000000000240024 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff8880608bff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
       ffff8880608c0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      >ffff8880608c0080: 00 00 00 00 fc fc fc fc fc fc fc fc 00 00 00 00
                                     ^
       ffff8880608c0100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
       ffff8880608c0180: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
      ==================================================================
      
      Link: https://lore.kernel.org/linux-media/1620723603-30912-1-git-send-email-zheyuma97@gmail.comReported-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      b1320303
    • Cai Huoqing's avatar
      media: dvb-core: Convert to SPDX identifier · 8d395ce6
      Cai Huoqing authored
      use SPDX-License-Identifier instead of a verbose license text
      and remove verbose license text.
      
      Link: https://lore.kernel.org/linux-media/20210916020018.8550-1-caihuoqing@baidu.comSigned-off-by: default avatarCai Huoqing <caihuoqing@baidu.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      8d395ce6
    • Wang Hai's avatar
      media: dmxdev: fix UAF when dvb_register_device() fails · ab599eb1
      Wang Hai authored
      I got a use-after-free report:
      
      dvbdev: dvb_register_device: failed to create device dvb1.dvr0 (-12)
      ...
      ==================================================================
      BUG: KASAN: use-after-free in dvb_dmxdev_release+0xce/0x2f0
      ...
      Call Trace:
       dump_stack_lvl+0x6c/0x8b
       print_address_description.constprop.0+0x48/0x70
       kasan_report.cold+0x82/0xdb
       __asan_load4+0x6b/0x90
       dvb_dmxdev_release+0xce/0x2f0
      ...
      Allocated by task 7666:
       kasan_save_stack+0x23/0x50
       __kasan_kmalloc+0x83/0xa0
       kmem_cache_alloc_trace+0x22e/0x470
       dvb_register_device+0x12f/0x980
       dvb_dmxdev_init+0x1f3/0x230
      ...
      Freed by task 7666:
       kasan_save_stack+0x23/0x50
       kasan_set_track+0x20/0x30
       kasan_set_free_info+0x24/0x40
       __kasan_slab_free+0xf2/0x130
       kfree+0xd1/0x5c0
       dvb_register_device.cold+0x1ac/0x1fa
       dvb_dmxdev_init+0x1f3/0x230
      ...
      
      When dvb_register_device() in dvb_dmxdev_init() fails, dvb_dmxdev_init()
      does not return a failure, and the memory pointed to by dvbdev or
      dvr_dvbdev is invalid at this point. If they are used subsequently, it
      will result in UFA or null-ptr-deref.
      
      If dvb_register_device() in dvb_dmxdev_init() fails, fix the bug by making
      dvb_dmxdev_init() return an error as well.
      
      Link: https://lore.kernel.org/linux-media/20211015085741.1203283-1-wanghai38@huawei.com
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      ab599eb1
    • Martin Weber's avatar
      media: coda: V4L2_PIX_FMT_GREY for coda960 JPEG Encoder · ea8587d9
      Martin Weber authored
      support greyscale pix fmt input for coda9_jpeg_encoder. The hardware
      supports it, so allow V4L2 Mem2Mem JPEG Encoder use it as well. Tested
      on an i.MX6QP.
      
      [hverkuil: updated the Subject line as suggested by Philipp]
      Signed-off-by: default avatarMartin Weber <martin.weber@br-automation.com>
      Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      ea8587d9