1. 04 5月, 2018 6 次提交
  2. 17 4月, 2018 1 次提交
    • D
      media: ddbridge: don't uselessly check for dma in start/stop functions · 8b8fcf32
      Daniel Scheller 提交于
      The check for a valid ptr in ddb_io->dma isn't really necessary since only
      devices that do data transport using DMA are supported by the driver, and
      all previous initialisation code (through input_init(), output_init() and
      dma_init(), has_dma is always true as it's set in ddb_probe() during
      driver load) guarantees the ptr is set.
      
      As a side effect, this silences these sparse warnings (albeit them being
      false positives as ddb_io->dma won't change in these functions so the
      condition always equals to the same result):
      
          drivers/media/pci/ddbridge/ddbridge-core.c:495:9: warning: context imbalance in 'ddb_output_start' - different lock contexts for basic block
          drivers/media/pci/ddbridge/ddbridge-core.c:510:9: warning: context imbalance in 'ddb_output_stop' - different lock contexts for basic block
          drivers/media/pci/ddbridge/ddbridge-core.c:525:9: warning: context imbalance in 'ddb_input_stop' - different lock contexts for basic block
          drivers/media/pci/ddbridge/ddbridge-core.c:560:9: warning: context imbalance in 'ddb_input_start' - different lock contexts for basic block
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      8b8fcf32
  3. 08 3月, 2018 1 次提交
  4. 12 2月, 2018 1 次提交
    • L
      vfs: do bulk POLL* -> EPOLL* replacement · a9a08845
      Linus Torvalds 提交于
      This is the mindless scripted replacement of kernel use of POLL*
      variables as described by Al, done by this script:
      
          for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
              L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
              for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
          done
      
      with de-mangling cleanups yet to come.
      
      NOTE! On almost all architectures, the EPOLL* constants have the same
      values as the POLL* constants do.  But they keyword here is "almost".
      For various bad reasons they aren't the same, and epoll() doesn't
      actually work quite correctly in some cases due to this on Sparc et al.
      
      The next patch from Al will sort out the final differences, and we
      should be all done.
      Scripted-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      a9a08845
  5. 19 12月, 2017 7 次提交
    • D
      media: ddbridge: move CI detach code to ddbridge-ci.c · 12081a25
      Daniel Scheller 提交于
      Move the CI teardown code to ddbridge-ci.c where everything else related
      to CI hardware lives.
      
      Cc: Ralph Metzler <rjkm@metzlerbros.de>
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      12081a25
    • D
      media: ddbridge: improve ddb_ports_attach() failure handling · ae494328
      Daniel Scheller 提交于
      As all error handling improved quite a bit, don't stop attaching frontends
      if one of them failed, since - if other tuner modules are connected to
      the PCIe bridge - other hardware may just work, so don't break on a single
      port failure, but rather initialise as much as possible. Ie. if there are
      issues with a C2T2-equipped PCIe bridge card which has additional DuoFlex
      modules connected and the bridge generally works, the DuoFlex tuners can
      still work fine.
      
      If all ports failed to initialise where connected hardware was detected on
      at first, return -ENODEV though to cause this PCI device to fail and free
      all allocated resources. In any case, leave a kernel log warning (or
      error, even) if things went wrong.
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      ae494328
    • D
      media: ddbridge: detach first input if the second one failed to init · c0e10260
      Daniel Scheller 提交于
      In ddb_ports_attach(), if the second input of a dual tuner failed to
      initialise, the first one can be detached (and resources be freed) as
      this will be counted as the whole port having failed to initialise,
      thus the first one won't be used anyway.
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      c0e10260
    • D
      media: ddbridge: fix deinit order in case of failure in ddb_init() · b7b9a5a9
      Daniel Scheller 提交于
      In ddb_init(), the deinitialization sequence isn't correct when handling
      errors, and could even lead to a memleak depending on where things failed.
      Fix the deinit order.
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      b7b9a5a9
    • D
      media: ddbridge: completely tear down input resources on failure · 25ac563a
      Daniel Scheller 提交于
      In dvb_input_attach(), whenever a demod driver fails to initialise, or if
      frontend registration fails, perform a full input/frontend teardown using
      dvb_input_detach() (which can safely be done since the current init state
      is tracked in the 'attached' struct member). Claimed resources thus are
      freed which aren't needed when an input or a port is not functional.
      
      While at it, in ddb_ports_detach(), detach the secondary input first. Also
      increase the kernlog severity of TDA18212 errors and tuner failures in
      general.
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      25ac563a
    • D
      media: ddbridge: fix resources cleanup for CI hardware · fac37bb1
      Daniel Scheller 提交于
      Do kfree() on port->en->data instead of port->en. port->en only holds a
      ptr to a struct dvb_ca_en50221, which is a member either of a memalloc'ed
      struct ddb_ci (DuoFlex CI, Octopus CI Duo) or a struct cxd (CXD2099AR
      based Single Flex, allocated by the cxd2099 driver). port->en.data
      though holds the ptr to the allocated memory, which must rather be
      kfree()'d. Change this accordingly.
      
      Cc: Ralph Metzler <rjkm@metzlerbros.de>
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      fac37bb1
    • D
      media: ddbridge: unregister I2C tuner client before detaching fe's · a1c484b3
      Daniel Scheller 提交于
      Currently, rmmod ddbridge on a KASAN enabled kernel yields this report
      for hardware that utilises the tda18212 tuner driver:
      
        [   50.355229] ==================================================================
        [   50.355271] BUG: KASAN: use-after-free in tda18212_remove+0x5c/0xb0 [tda18212]
        [   50.355290] Write of size 288 at addr ffff8800c235cf18 by task rmmod/285
      
        [   50.355316] CPU: 1 PID: 285 Comm: rmmod Not tainted 4.15.0-rc1-13744-g352a86ad536f #11
        [   50.355318] Hardware name: Gigabyte Technology Co., Ltd. P35-DS3/P35-DS3, BIOS F3 06/11/2007
        [   50.355319] Call Trace:
        [   50.355326]  dump_stack+0x46/0x61
        [   50.355332]  print_address_description+0x79/0x270
        [   50.355336]  ? tda18212_remove+0x5c/0xb0 [tda18212]
        [   50.355339]  kasan_report+0x229/0x340
        [   50.355342]  memset+0x1f/0x40
        [   50.355345]  tda18212_remove+0x5c/0xb0 [tda18212]
        [   50.355350]  i2c_device_remove+0x97/0xe0
        [   50.355355]  device_release_driver_internal+0x267/0x510
        [   50.355358]  bus_remove_device+0x296/0x470
        [   50.355360]  device_del+0x35c/0x890
        [   50.355363]  ? __device_links_no_driver+0x1c0/0x1c0
        [   50.355367]  ? cxd2841er_get_algo+0x10/0x10 [cxd2841er]
        [   50.355371]  ? cxd2841er_get_algo+0x10/0x10 [cxd2841er]
        [   50.355374]  ? __module_text_address+0xe/0x140
        [   50.355377]  device_unregister+0x9/0x20
        [   50.355382]  dvb_input_detach.isra.24+0x286/0x480 [ddbridge]
        [   50.355388]  ddb_ports_detach+0x15f/0x4f0 [ddbridge]
        [   50.355393]  ddb_remove+0x3c/0xb0 [ddbridge]
        [   50.355397]  pci_device_remove+0x93/0x1d0
        [   50.355400]  device_release_driver_internal+0x267/0x510
        [   50.355403]  driver_detach+0xb9/0x1b0
        [   50.355406]  bus_remove_driver+0xd0/0x1f0
        [   50.355410]  pci_unregister_driver+0x25/0x210
        [   50.355415]  module_exit_ddbridge+0xc/0x45 [ddbridge]
        [   50.355418]  SyS_delete_module+0x314/0x440
        [   50.355420]  ? free_module+0x5b0/0x5b0
        [   50.355423]  ? exit_to_usermode_loop+0xa9/0xc0
        [   50.355425]  ? free_module+0x5b0/0x5b0
        [   50.355428]  do_syscall_64+0x179/0x4c0
        [   50.355432]  ? do_page_fault+0x1b/0x60
        [   50.355435]  entry_SYSCALL64_slow_path+0x25/0x25
        [   50.355438] RIP: 0033:0x7fe65d08ade7
        [   50.355439] RSP: 002b:00007fff5a6a09a8 EFLAGS: 00000202 ORIG_RAX: 00000000000000b0
        [   50.355443] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe65d08ade7
        [   50.355445] RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000000000f4e268
        [   50.355447] RBP: 0000000000f4e200 R08: 0000000000000000 R09: 1999999999999999
        [   50.355449] R10: 0000000000000891 R11: 0000000000000202 R12: 00007fff5a6a14ef
        [   50.355451] R13: 0000000000000000 R14: 0000000000f4e200 R15: 0000000000f4d010
      
        [   50.355462] Allocated by task 164:
        [   50.355477]  cxd2841er_attach+0xc3/0x7f0 [cxd2841er]
        [   50.355482]  demod_attach_cxd28xx+0x14c/0x3f0 [ddbridge]
        [   50.355486]  dvb_input_attach+0x671/0x1e20 [ddbridge]
        [   50.355490]  ddb_ports_attach+0x3d7/0xbf0 [ddbridge]
        [   50.355495]  ddb_init+0x4b3/0xa30 [ddbridge]
        [   50.355499]  ddb_probe+0xa51/0xfe0 [ddbridge]
        [   50.355501]  pci_device_probe+0x279/0x480
        [   50.355504]  driver_probe_device+0x46f/0x7a0
        [   50.355506]  __driver_attach+0x133/0x170
        [   50.355509]  bus_for_each_dev+0x10a/0x190
        [   50.355511]  bus_add_driver+0x2a3/0x5a0
        [   50.355513]  driver_register+0x182/0x3a0
        [   50.355516]  arc4_set_key+0x8f/0x2a0 [arc4]
        [   50.355518]  do_one_initcall+0x77/0x1d0
        [   50.355521]  do_init_module+0x1c2/0x548
        [   50.355523]  load_module+0x5e61/0x8df0
        [   50.355525]  SyS_finit_module+0x142/0x150
        [   50.355527]  do_syscall_64+0x179/0x4c0
        [   50.355529]  return_from_SYSCALL_64+0x0/0x65
      
        [   50.355539] Freed by task 285:
        [   50.355551]  kfree+0x6c/0xa0
        [   50.355558]  __dvb_frontend_free+0x81/0xb0 [dvb_core]
        [   50.355562]  dvb_input_detach.isra.24+0x17c/0x480 [ddbridge]
        [   50.355566]  ddb_ports_detach+0x15f/0x4f0 [ddbridge]
        [   50.355570]  ddb_remove+0x3c/0xb0 [ddbridge]
        [   50.355573]  pci_device_remove+0x93/0x1d0
        [   50.355576]  device_release_driver_internal+0x267/0x510
        [   50.355578]  driver_detach+0xb9/0x1b0
        [   50.355580]  bus_remove_driver+0xd0/0x1f0
        [   50.355583]  pci_unregister_driver+0x25/0x210
        [   50.355587]  module_exit_ddbridge+0xc/0x45 [ddbridge]
        [   50.355590]  SyS_delete_module+0x314/0x440
        [   50.355592]  do_syscall_64+0x179/0x4c0
        [   50.355594]  return_from_SYSCALL_64+0x0/0x65
      
        [   50.355604] The buggy address belongs to the object at ffff8800c235cd80
                        which belongs to the cache kmalloc-2048 of size 2048
        [   50.355630] The buggy address is located 408 bytes inside of
                        2048-byte region [ffff8800c235cd80, ffff8800c235d580)
        [   50.355652] The buggy address belongs to the page:
        [   50.355666] page:ffffea0002a7bc20 count:1 mapcount:0 mapping:ffff8800c235c500 index:0x0 compound_mapcount: 0
        [   50.355688] flags: 0x4000000000008100(slab|head)
        [   50.355703] raw: 4000000000008100 ffff8800c235c500 0000000000000000 0000000100000003
        [   50.355720] raw: ffffea000382b4b0 ffffea0002b91550 ffff88010b000800
        [   50.355734] page dumped because: kasan: bad access detected
      
        [   50.355754] Memory state around the buggy address:
        [   50.355767]  ffff8800c235ce00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [   50.355783]  ffff8800c235ce80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [   50.355800] >ffff8800c235cf00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [   50.355815]                             ^
        [   50.355827]  ffff8800c235cf80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [   50.355843]  ffff8800c235d000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [   50.355858] ==================================================================
      
      This is due to dvb_frontend_detach() being called before
      i2c_unregister_device() on the TDA18212 tuner client instance, as
      dvb_frontend_detach() causes the demod drivers to release all their
      resources, and the tuner driver's _remove method does further cleanup on
      the now invalid (freed) resources. Fix this by putting the I2C client
      deregistration in dvb_input_detach() to state/case 0x30, right before the
      call to dvb_frontend_detach(). This also makes sure that any further
      (tuner) hardware driven by I2C client drivers unload cleanly.
      
      Fixes: 1502efd2 ("media: ddbridge: fix teardown/deregistration order in ddb_input_detach()")
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      a1c484b3
  6. 15 12月, 2017 1 次提交
  7. 13 12月, 2017 1 次提交
  8. 12 12月, 2017 5 次提交
  9. 28 11月, 2017 1 次提交
  10. 27 8月, 2017 2 次提交
    • D
      media: ddbridge: fix sparse warnings · b5967860
      Daniel Scheller 提交于
      Fix several
      
        drivers/media/pci/ddbridge/ddbridge-core.c: warning: symbol ... was not declared. Should it be static?
        drivers/media/pci/ddbridge/ddbridge-core.c: warning: Using plain integer as NULL pointer
        drivers/media/pci/ddbridge/ddbridge-io.h: warning: cast removes address space of expression
        drivers/media/pci/ddbridge/ddbridge-io.h: warning: incorrect type in argument 1 (different address spaces)
      
      at multiple places.
      
      Cc: Ralph Metzler <rjkm@metzlerbros.de>
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      b5967860
    • D
      media: ddbridge: fix teardown/deregistration order in ddb_input_detach() · 1502efd2
      Daniel Scheller 提交于
      Brought to attention by Matthias Schwarzott <zzam@gentoo.org> by fixing
      possible use-after-free faults in some demod drivers:
      
      In ddb_input_detach(), the i2c_client is unregistered and removed before
      dvb frontends are unregistered and detached. While no use-after-free issue
      was observed so far, there is another issue with this:
      
      dvb->attached keeps track of the state of the input/output registration,
      and the i2c_client unregistration takes place only if everything was
      successful (dvb->attached == 0x31). If for some reason an error occurred
      during the frontend setup, that value stays at 0x20. In the following
      error handling and cleanup, ddb_input_detach() will skip down to that
      state, leaving the i2c_client registered, causing refcount issues.
      
      Fix this by moving the i2c_client deregistration down to case 0x20.
      
      Cc: Matthias Schwarzott <zzam@gentoo.org>
      Signed-off-by: NDaniel Scheller <d.scheller@gmx.net>
      Signed-off-by: NMauro Carvalho Chehab <mchehab@s-opensource.com>
      1502efd2
  11. 20 8月, 2017 14 次提交