Skip to content
  1. Dec 17, 2021
    • Shiraz Saleem's avatar
      RDMA/irdma: Report correct WC errors · 918e6251
      Shiraz Saleem authored
      [ Upstream commit 25b5d6fd ]
      
      Return IBV_WC_REM_OP_ERR for responder QP errors instead of
      IBV_WC_REM_ACCESS_ERR.
      
      Return IBV_WC_LOC_QP_OP_ERR for errors detected on the SQ with bad opcodes
      
      Fixes: 44d9e529
      
       ("RDMA/irdma: Implement device initialization definitions")
      Link: https://lore.kernel.org/r/20211201231509.1930-1-shiraz.saleem@intel.com
      Signed-off-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      918e6251
    • Christophe JAILLET's avatar
      RDMA/irdma: Fix a potential memory allocation issue in 'irdma_prm_add_pble_mem()' · b260dfed
      Christophe JAILLET authored
      [ Upstream commit 117697cc ]
      
      'pchunk->bitmapbuf' is a bitmap. Its size (in number of bits) is stored in
      'pchunk->sizeofbitmap'.
      
      When it is allocated, the size (in bytes) is computed by:
         size_in_bits >> 3
      
      There are 2 issues (numbers bellow assume that longs are 64 bits):
         - there is no guarantee here that 'pchunk->bitmapmem.size' is modulo
           BITS_PER_LONG but bitmaps are stored as longs
           (sizeofbitmap=8 bits will only allocate 1 byte, instead of 8 (1 long))
      
         - the number of bytes is computed with a shift, not a round up, so we
           may allocate less memory than needed
           (sizeofbitmap=65 bits will only allocate 8 bytes (i.e. 1 long), when 2
           longs are needed = 16 bytes)
      
      Fix both issues by using 'bitmap_zalloc()' and remove the useless
      'bitmapmem' from 'struct irdma_chunk'.
      
      While at it, remove some useless NULL test before calling
      kfree/bitmap_free.
      
      Fixes: 915cc7ac
      
       ("RDMA/irdma: Add miscellaneous utility definitions")
      Link: https://lore.kernel.org/r/5e670b640508e14b1869c3e8e4fb970d78cbe997.1638692171.git.christophe.jaillet@wanadoo.fr
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Reviewed-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b260dfed
    • Shiraz Saleem's avatar
      RDMA/irdma: Fix a user-after-free in add_pble_prm · 11eebcf6
      Shiraz Saleem authored
      [ Upstream commit 1e11a39a ]
      
      When irdma_hmc_sd_one fails, 'chunk' is freed while its still on the PBLE
      info list.
      
      Add the chunk entry to the PBLE info list only after successful setting of
      the SD in irdma_hmc_sd_one.
      
      Fixes: e8c4dbc2
      
       ("RDMA/irdma: Add PBLE resource manager")
      Link: https://lore.kernel.org/r/20211207152135.2192-1-shiraz.saleem@intel.com
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      11eebcf6
    • David Howells's avatar
      netfs: Fix lockdep warning from taking sb_writers whilst holding mmap_lock · 1ac287b7
      David Howells authored
      [ Upstream commit 598ad0bd ]
      
      Taking sb_writers whilst holding mmap_lock isn't allowed and will result in
      a lockdep warning like that below.  The problem comes from cachefiles
      needing to take the sb_writers lock in order to do a write to the cache,
      but being asked to do this by netfslib called from readpage, readahead or
      write_begin[1].
      
      Fix this by always offloading the write to the cache off to a worker
      thread.  The main thread doesn't need to wait for it, so deadlock can be
      avoided.
      
      This can be tested by running the quick xfstests on something like afs or
      ceph with lockdep enabled.
      
      WARNING: possible circular locking dependency detected
      5.15.0-rc1-build2+ #292 Not tainted
      ------------------------------------------------------
      holetest/65517 is trying to acquire lock:
      ffff88810c81d730 (mapping.invalidate_lock#3){.+.+}-{3:3}, at: filemap_fault+0x276/0x7a5
      
      but task is already holding lock:
      ffff8881595b53e8 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault+0x28d/0x59c
      
      which lock already depends on the new lock.
      
      the existing dependency chain (in reverse order) is:
      
      -> #2 (&mm->mmap_lock#2){++++}-{3:3}:
             validate_chain+0x3c4/0x4a8
             __lock_acquire+0x89d/0x949
             lock_acquire+0x2dc/0x34b
             __might_fault+0x87/0xb1
             strncpy_from_user+0x25/0x18c
             removexattr+0x7c/0xe5
             __do_sys_fremovexattr+0x73/0x96
             do_syscall_64+0x67/0x7a
             entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      -> #1 (sb_writers#10){.+.+}-{0:0}:
             validate_chain+0x3c4/0x4a8
             __lock_acquire+0x89d/0x949
             lock_acquire+0x2dc/0x34b
             cachefiles_write+0x2b3/0x4bb
             netfs_rreq_do_write_to_cache+0x3b5/0x432
             netfs_readpage+0x2de/0x39d
             filemap_read_page+0x51/0x94
             filemap_get_pages+0x26f/0x413
             filemap_read+0x182/0x427
             new_sync_read+0xf0/0x161
             vfs_read+0x118/0x16e
             ksys_read+0xb8/0x12e
             do_syscall_64+0x67/0x7a
             entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      -> #0 (mapping.invalidate_lock#3){.+.+}-{3:3}:
             check_noncircular+0xe4/0x129
             check_prev_add+0x16b/0x3a4
             validate_chain+0x3c4/0x4a8
             __lock_acquire+0x89d/0x949
             lock_acquire+0x2dc/0x34b
             down_read+0x40/0x4a
             filemap_fault+0x276/0x7a5
             __do_fault+0x96/0xbf
             do_fault+0x262/0x35a
             __handle_mm_fault+0x171/0x1b5
             handle_mm_fault+0x12a/0x233
             do_user_addr_fault+0x3d2/0x59c
             exc_page_fault+0x85/0xa5
             asm_exc_page_fault+0x1e/0x30
      
      other info that might help us debug this:
      
      Chain exists of:
        mapping.invalidate_lock#3 --> sb_writers#10 --> &mm->mmap_lock#2
      
       Possible unsafe locking scenario:
      
             CPU0                    CPU1
             ----                    ----
        lock(&mm->mmap_lock#2);
                                     lock(sb_writers#10);
                                     lock(&mm->mmap_lock#2);
        lock(mapping.invalidate_lock#3);
      
       *** DEADLOCK ***
      
      1 lock held by holetest/65517:
       #0: ffff8881595b53e8 (&mm->mmap_lock#2){++++}-{3:3}, at: do_user_addr_fault+0x28d/0x59c
      
      stack backtrace:
      CPU: 0 PID: 65517 Comm: holetest Not tainted 5.15.0-rc1-build2+ #292
      Hardware name: ASUS All Series/H97-PLUS, BIOS 2306 10/09/2014
      Call Trace:
       dump_stack_lvl+0x45/0x59
       check_noncircular+0xe4/0x129
       ? print_circular_bug+0x207/0x207
       ? validate_chain+0x461/0x4a8
       ? add_chain_block+0x88/0xd9
       ? hlist_add_head_rcu+0x49/0x53
       check_prev_add+0x16b/0x3a4
       validate_chain+0x3c4/0x4a8
       ? check_prev_add+0x3a4/0x3a4
       ? mark_lock+0xa5/0x1c6
       __lock_acquire+0x89d/0x949
       lock_acquire+0x2dc/0x34b
       ? filemap_fault+0x276/0x7a5
       ? rcu_read_unlock+0x59/0x59
       ? add_to_page_cache_lru+0x13c/0x13c
       ? lock_is_held_type+0x7b/0xd3
       down_read+0x40/0x4a
       ? filemap_fault+0x276/0x7a5
       filemap_fault+0x276/0x7a5
       ? pagecache_get_page+0x2dd/0x2dd
       ? __lock_acquire+0x8bc/0x949
       ? pte_offset_kernel.isra.0+0x6d/0xc3
       __do_fault+0x96/0xbf
       ? do_fault+0x124/0x35a
       do_fault+0x262/0x35a
       ? handle_pte_fault+0x1c1/0x20d
       __handle_mm_fault+0x171/0x1b5
       ? handle_pte_fault+0x20d/0x20d
       ? __lock_release+0x151/0x254
       ? mark_held_locks+0x1f/0x78
       ? rcu_read_unlock+0x3a/0x59
       handle_mm_fault+0x12a/0x233
       do_user_addr_fault+0x3d2/0x59c
       ? pgtable_bad+0x70/0x70
       ? rcu_read_lock_bh_held+0xab/0xab
       exc_page_fault+0x85/0xa5
       ? asm_exc_page_fault+0x8/0x30
       asm_exc_page_fault+0x1e/0x30
      RIP: 0033:0x40192f
      Code: ff 48 89 c3 48 8b 05 50 28 00 00 48 85 ed 7e 23 31 d2 4b 8d 0c 2f eb 0a 0f 1f 00 48 8b 05 39 28 00 00 48 0f af c2 48 83 c2 01 <48> 89 1c 01 48 39 d5 7f e8 8b 0d f2 27 00 00 31 c0 85 c9 74 0e 8b
      RSP: 002b:00007f9931867eb0 EFLAGS: 00010202
      RAX: 0000000000000000 RBX: 00007f9931868700 RCX: 00007f993206ac00
      RDX: 0000000000000001 RSI: 0000000000000000 RDI: 00007ffc13e06ee0
      RBP: 0000000000000100 R08: 0000000000000000 R09: 00007f9931868700
      R10: 00007f99318689d0 R11: 0000000000000202 R12: 00007ffc13e06ee0
      R13: 0000000000000c00 R14: 00007ffc13e06e00 R15: 00007f993206a000
      
      Fixes: 726218fd
      
       ("netfs: Define an interface to talk to a cache")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Tested-by: default avatarJeff Layton <jlayton@kernel.org>
      cc: Jan Kara <jack@suse.cz>
      cc: linux-cachefs@redhat.com
      cc: linux-fsdevel@vger.kernel.org
      Link: https://lore.kernel.org/r/20210922110420.GA21576@quack2.suse.cz/ [1]
      Link: https://lore.kernel.org/r/163887597541.1596626.2668163316598972956.stgit@warthog.procyon.org.uk/ # v1
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ac287b7
    • Song Liu's avatar
      perf bpf_skel: Do not use typedef to avoid error on old clang · cff72821
      Song Liu authored
      [ Upstream commit 5a897531 ]
      
      When building bpf_skel with clang-10, typedef causes confusions like:
      
        libbpf: map 'prev_readings': unexpected def kind var.
      
      Fix this by removing the typedef.
      
      Fixes: 7fac83aa
      
       ("perf stat: Introduce 'bperf' to share hardware PMCs with BPF")
      Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/BEF5C312-4331-4A60-AEC0-AD7617CB2BC4@fb.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cff72821
    • Martin Botka's avatar
      clk: qcom: sm6125-gcc: Swap ops of ice and apps on sdcc1 · 134151c3
      Martin Botka authored
      [ Upstream commit e53f2086
      
       ]
      
      Without this change eMMC runs at overclocked freq.
      Swap the ops to not OC the eMMC.
      
      Signed-off-by: default avatarMartin Botka <martin.botka@somainline.org>
      Link: https://lore.kernel.org/r/20211130212015.25232-1-martin.botka@somainline.org
      Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Fixes: 4b8d6ae5
      
       ("clk: qcom: Add SM6125 (TRINKET) GCC driver")
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      134151c3
    • Rob Herring's avatar
      dt-bindings: media: nxp,imx7-mipi-csi2: Drop bad if/then schema · 439250c0
      Rob Herring authored
      [ Upstream commit b54472a0 ]
      
      The if/then schema for 'data-lanes' doesn't work as 'compatible' is at a
      different level than 'data-lanes'. To make it work, the if/then schema
      would have to be moved to the top level and then whole hierarchy of
      nodes down to 'data-lanes' created. I don't think it is worth the
      complexity to do that, so let's just drop it.
      
      The error in this schema is masked by a fixup in the tools causing the
      'allOf' to get overwritten. Removing the fixup as part of moving to
      json-schema draft 2019-09 revealed the issue:
      
      Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.example.dt.yaml: mipi-csi@30750000: ports:port@0:endpoint:data-lanes:0: [1] is too short
      	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml
      Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.example.dt.yaml: mipi-csi@32e30000: ports:port@0:endpoint:data-lanes:0: [1, 2, 3, 4] is too long
      	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/media/nxp,imx7-mipi-csi2.yaml
      
      The if condition was always true because 'compatible' did not exist in
      'endpoint' node and a non-existent property is true for json-schema.
      
      Fixes: 85b62ff2
      
       ("media: dt-bindings: media: nxp,imx7-mipi-csi2: Add i.MX8MM support")
      Cc: Rui Miguel Silva <rmfrfs@gmail.com>
      Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
      Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Pengutronix Kernel Team <kernel@pengutronix.de>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: NXP Linux Team <linux-imx@nxp.com>
      Cc: linux-media@vger.kernel.org
      Cc: linux-arm-kernel@lists.infradead.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
      Link: https://lore.kernel.org/r/20211203164828.187642-1-robh@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      439250c0
    • Eric Dumazet's avatar
      inet: use #ifdef CONFIG_SOCK_RX_QUEUE_MAPPING consistently · d17a8d12
      Eric Dumazet authored
      [ Upstream commit a9418924 ]
      
      Since commit 4e1beecc ("net/sock: Add kernel config
      SOCK_RX_QUEUE_MAPPING"),
      sk_rx_queue_mapping access is guarded by CONFIG_SOCK_RX_QUEUE_MAPPING.
      
      Fixes: 54b92e84
      
       ("tcp: Migrate TCP_ESTABLISHED/TCP_SYN_RECV sockets in accept queues.")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Kuniyuki Iwashima <kuniyu@amazon.co.jp>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Tariq Toukan <tariqt@nvidia.com>
      Acked-by: default avatarKuniyuki Iwashima <kuniyu@amazon.co.jp>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d17a8d12
    • Herve Codina's avatar
      mtd: rawnand: Fix nand_choose_best_timings() on unsupported interface · c6aa8873
      Herve Codina authored
      [ Upstream commit 36a65982 ]
      
      When the NV-DDR interface is not supported by the NAND chip,
      the value of onfi->nvddr_timing_modes is 0. In this case,
      the best_mode variable value in nand_choose_best_nvddr_timings()
      is -1. The last for-loop is skipped and the function returns an
      uninitialized value.
      If this returned value is 0, the nand_choose_best_sdr_timings()
      is not executed and no 'best timing' are set. This leads the host
      controller and the NAND chip working at default mode 0 timing
      even if a better timing can be used.
      
      Fix this uninitialized returned value.
      
      nand_choose_best_sdr_timings() is pretty similar to
      nand_choose_best_nvddr_timings(). Even if onfi->sdr_timing_modes
      should never be seen as 0, nand_choose_best_sdr_timings() returned
      value is fixed.
      
      Fixes: a9ecc8c8
      
       ("mtd: rawnand: Choose the best timings, NV-DDR included")
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20211119150316.43080-3-herve.codina@bootlin.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c6aa8873
    • Herve Codina's avatar
      mtd: rawnand: Fix nand_erase_op delay · 0c7b4888
      Herve Codina authored
      [ Upstream commit 16d8b628 ]
      
      NAND_OP_CMD() expects a delay parameter in nanoseconds.
      The delay value is wrongly given in milliseconds.
      
      Fix the conversion macro used in order to set this
      delay in nanoseconds.
      
      Fixes: d7a773e8
      
       ("mtd: rawnand: Access SDR and NV-DDR timings through a common macro")
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/linux-mtd/20211119150316.43080-2-herve.codina@bootlin.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0c7b4888
    • Alaa Hleihel's avatar
      RDMA/mlx5: Fix releasing unallocated memory in dereg MR flow · e3bc4d4b
      Alaa Hleihel authored
      [ Upstream commit f0ae4afe ]
      
      For the case of IB_MR_TYPE_DM the mr does doesn't have a umem, even though
      it is a user MR. This causes function mlx5_free_priv_descs() to think that
      it is a kernel MR, leading to wrongly accessing mr->descs that will get
      wrong values in the union which leads to attempt to release resources that
      were not allocated in the first place.
      
      For example:
       DMA-API: mlx5_core 0000:08:00.1: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=0 bytes]
       WARNING: CPU: 8 PID: 1021 at kernel/dma/debug.c:961 check_unmap+0x54f/0x8b0
       RIP: 0010:check_unmap+0x54f/0x8b0
       Call Trace:
        debug_dma_unmap_page+0x57/0x60
        mlx5_free_priv_descs+0x57/0x70 [mlx5_ib]
        mlx5_ib_dereg_mr+0x1fb/0x3d0 [mlx5_ib]
        ib_dereg_mr_user+0x60/0x140 [ib_core]
        uverbs_destroy_uobject+0x59/0x210 [ib_uverbs]
        uobj_destroy+0x3f/0x80 [ib_uverbs]
        ib_uverbs_cmd_verbs+0x435/0xd10 [ib_uverbs]
        ? uverbs_finalize_object+0x50/0x50 [ib_uverbs]
        ? lock_acquire+0xc4/0x2e0
        ? lock_acquired+0x12/0x380
        ? lock_acquire+0xc4/0x2e0
        ? lock_acquire+0xc4/0x2e0
        ? ib_uverbs_ioctl+0x7c/0x140 [ib_uverbs]
        ? lock_release+0x28a/0x400
        ib_uverbs_ioctl+0xc0/0x140 [ib_uverbs]
        ? ib_uverbs_ioctl+0x7c/0x140 [ib_uverbs]
        __x64_sys_ioctl+0x7f/0xb0
        do_syscall_64+0x38/0x90
      
      Fix it by reorganizing the dereg flow and mlx5_ib_mr structure:
       - Move the ib_umem field into the user MRs structure in the union as it's
         applicable only there.
       - Function mlx5_ib_dereg_mr() will now call mlx5_free_priv_descs() only
         in case there isn't udata, which indicates that this isn't a user MR.
      
      Fixes: f18ec422
      
       ("RDMA/mlx5: Use a union inside mlx5_ib_mr")
      Link: https://lore.kernel.org/r/66bb1dd253c1fd7ceaa9fc411061eefa457b86fb.1637581144.git.leonro@nvidia.com
      Signed-off-by: default avatarAlaa Hleihel <alaa@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3bc4d4b
    • Pavel Skripkin's avatar
      RDMA: Fix use-after-free in rxe_queue_cleanup · acb53e47
      Pavel Skripkin authored
      [ Upstream commit 84b01721 ]
      
      On error handling path in rxe_qp_from_init() qp->sq.queue is freed and
      then rxe_create_qp() will drop last reference to this object. qp clean up
      function will try to free this queue one time and it causes UAF bug.
      
      Fix it by zeroing queue pointer after freeing queue in rxe_qp_from_init().
      
      Fixes: 514aee66
      
       ("RDMA: Globally allocate and release QP memory")
      Link: https://lore.kernel.org/r/20211121202239.3129-1-paskripkin@gmail.com
      Reported-by: default avatar <syzbot+aab53008a5adf26abe91@syzkaller.appspotmail.com>
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Reviewed-by: default avatarZhu Yanjun <zyjzyj2000@gmail.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      acb53e47
    • Wilken Gottwalt's avatar
      hwmon: (corsair-psu) fix plain integer used as NULL pointer · c0d44c58
      Wilken Gottwalt authored
      [ Upstream commit 83832265 ]
      
      sparse warnings: (new ones prefixed by >>)
      >> drivers/hwmon/corsair-psu.c:536:82: sparse: sparse: Using plain
         integer as NULL pointer
      
      Fixes: d115b51e
      
       ("hwmon: add Corsair PSU HID controller driver")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarWilken Gottwalt <wilken.gottwalt@posteo.net>
      Link: https://lore.kernel.org/r/YY9hAL8MZEQYLYPf@monster.localdomain
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c0d44c58
    • Tadeusz Struk's avatar
      nfc: fix segfault in nfc_genl_dump_devices_done · d89e4211
      Tadeusz Struk authored
      commit fd79a0cb
      
       upstream.
      
      When kmalloc in nfc_genl_dump_devices() fails then
      nfc_genl_dump_devices_done() segfaults as below
      
      KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
      CPU: 0 PID: 25 Comm: kworker/0:1 Not tainted 5.16.0-rc4-01180-g2a987e65025e-dirty #5
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-6.fc35 04/01/2014
      Workqueue: events netlink_sock_destruct_work
      RIP: 0010:klist_iter_exit+0x26/0x80
      Call Trace:
      <TASK>
      class_dev_iter_exit+0x15/0x20
      nfc_genl_dump_devices_done+0x3b/0x50
      genl_lock_done+0x84/0xd0
      netlink_sock_destruct+0x8f/0x270
      __sk_destruct+0x64/0x3b0
      sk_destruct+0xa8/0xd0
      __sk_free+0x2e8/0x3d0
      sk_free+0x51/0x90
      netlink_sock_destruct_work+0x1c/0x20
      process_one_work+0x411/0x710
      worker_thread+0x6fd/0xa80
      
      Link: https://syzkaller.appspot.com/bug?id=fc0fa5a53db9edd261d56e74325419faf18bd0df
      Reported-by: default avatar <syzbot+f9f76f4a0766420b4a02@syzkaller.appspotmail.com>
      Signed-off-by: default avatarTadeusz Struk <tadeusz.struk@linaro.org>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Link: https://lore.kernel.org/r/20211208182742.340542-1-tadeusz.struk@linaro.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d89e4211
  2. Dec 16, 2021
  3. Dec 14, 2021
    • Greg Kroah-Hartman's avatar
      Linux 5.15.8 · 43e577d7
      Greg Kroah-Hartman authored
      
      
      Link: https://lore.kernel.org/r/20211213092945.091487407@linuxfoundation.org
      Tested-by: default avatarFox Chen <foxhlchen@gmail.com>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarRudi Heitbaum <rudi@heitbaum.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v5.15.8
      43e577d7
    • Maxim Mikityanskiy's avatar
      bpf: Add selftests to cover packet access corner cases · c2bd1add
      Maxim Mikityanskiy authored
      commit b560b21f upstream.
      
      This commit adds BPF verifier selftests that cover all corner cases by
      packet boundary checks. Specifically, 8-byte packet reads are tested at
      the beginning of data and at the beginning of data_meta, using all kinds
      of boundary checks (all comparison operators: <, >, <=, >=; both
      permutations of operands: data + length compared to end, end compared to
      data + length). For each case there are three tests:
      
      1. Length is just enough for an 8-byte read. Length is either 7 or 8,
         depending on the comparison.
      
      2. Length is increased by 1 - should still pass the verifier. These
         cases are useful, because they failed before commit 2fa7d94a
      
      
         ("bpf: Fix the off-by-two error in range markings").
      
      3. Length is decreased by 1 - should be rejected by the verifier.
      
      Some existing tests are just renamed to avoid duplication.
      
      Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211207081521.41923-1-maximmi@nvidia.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2bd1add
    • Alexey Sheplyakov's avatar
      clocksource/drivers/dw_apb_timer_of: Fix probe failure · 5475fcf0
      Alexey Sheplyakov authored
      commit a663bd19 upstream.
      
      The driver refuses to probe with -EINVAL since the commit 5d9814df
      
      
      ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock
      available").
      
      Before the driver used to probe successfully if either "clock-freq" or
      "clock-frequency" properties has been specified in the device tree.
      
      That commit changed
      
      if (A && B)
      	panic("No clock nor clock-frequency property");
      
      into
      
      if (!A && !B)
      	return 0;
      
      That's a bug: the reverse of `A && B` is '!A || !B', not '!A && !B'
      
      Signed-off-by: default avatarVadim V. Vlasov <vadim.vlasov@elpitech.ru>
      Signed-off-by: default avatarAlexey Sheplyakov <asheplyakov@basealt.ru>
      Fixes: 5d9814df
      
       ("clocksource/drivers/dw_apb_timer_of: Add error handling if no clock available").
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Dinh Nguyen <dinguyen@kernel.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vadim V. Vlasov <vadim.vlasov@elpitech.ru>
      Acked-by: default avatarDinh Nguyen <dinguyen@kernel.org>
      Link: https://lore.kernel.org/r/20211109153401.157491-1-asheplyakov@basealt.ru
      Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5475fcf0
    • Jeya R's avatar
      misc: fastrpc: fix improper packet size calculation · ee610466
      Jeya R authored
      commit 3a1bf591 upstream.
      
      The buffer list is sorted and this is not being considered while
      calculating packet size. This would lead to improper copy length
      calculation for non-dmaheap buffers which would eventually cause
      sending improper buffers to DSP.
      
      Fixes: c68cfb71
      
       ("misc: fastrpc: Add support for context Invoke method")
      Reviewed-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Signed-off-by: default avatarJeya R <jeyr@codeaurora.org>
      Link: https://lore.kernel.org/r/1637771481-4299-1-git-send-email-jeyr@codeaurora.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee610466
    • Vladimir Murzin's avatar
      irqchip: nvic: Fix offset for Interrupt Priority Offsets · 62a8ee05
      Vladimir Murzin authored
      commit c5e0cbe2 upstream.
      
      According to ARM(v7M) ARM Interrupt Priority Offsets located at
      0xE000E400-0xE000E5EC, while 0xE000E300-0xE000E33C covers read-only
      Interrupt Active Bit Registers
      
      Fixes: 292ec080
      
       ("irqchip: Add support for ARMv7-M NVIC")
      Signed-off-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211201110259.84857-1-vladimir.murzin@arm.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62a8ee05
    • Wudi Wang's avatar
      irqchip/irq-gic-v3-its.c: Force synchronisation when issuing INVALL · 2d34992e
      Wudi Wang authored
      commit b383a42c
      
       upstream.
      
      INVALL CMD specifies that the ITS must ensure any caching associated with
      the interrupt collection defined by ICID is consistent with the LPI
      configuration tables held in memory for all Redistributors. SYNC is
      required to ensure that INVALL is executed.
      
      Currently, LPI configuration data may be inconsistent with that in the
      memory within a short period of time after the INVALL command is executed.
      
      Signed-off-by: default avatarWudi Wang <wangwudi@hisilicon.com>
      Signed-off-by: default avatarShaokun Zhang <zhangshaokun@hisilicon.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Fixes: cc2d3216
      
       ("irqchip: GICv3: ITS command queue")
      Link: https://lore.kernel.org/r/20211208015429.5007-1-zhangshaokun@hisilicon.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2d34992e
    • Xie Yongji's avatar
      aio: Fix incorrect usage of eventfd_signal_allowed() · 4a7c6550
      Xie Yongji authored
      commit 4b374986 upstream.
      
      We should defer eventfd_signal() to the workqueue when
      eventfd_signal_allowed() return false rather than return
      true.
      
      Fixes: b542e383
      
       ("eventfd: Make signal recursion protection a task bit")
      Signed-off-by: default avatarXie Yongji <xieyongji@bytedance.com>
      Link: https://lore.kernel.org/r/20210913111928.98-1-xieyongji@bytedance.com
      Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a7c6550
    • Pali Rohár's avatar
      irqchip/armada-370-xp: Fix support for Multi-MSI interrupts · d99d861c
      Pali Rohár authored
      commit d0a55350
      
       upstream.
      
      irq-armada-370-xp driver already sets MSI_FLAG_MULTI_PCI_MSI flag into
      msi_domain_info structure. But allocated interrupt numbers for Multi-MSI
      needs to be properly aligned otherwise devices send MSI interrupt with
      wrong number.
      
      Fix this issue by using function bitmap_find_free_region() instead of
      bitmap_find_next_zero_area() to allocate aligned interrupt numbers.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Fixes: a71b9412
      
       ("irqchip/armada-370-xp: Allow allocation of multiple MSIs")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211125130057.26705-2-pali@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d99d861c
    • Pali Rohár's avatar
      irqchip/armada-370-xp: Fix return value of armada_370_xp_msi_alloc() · 97912b97
      Pali Rohár authored
      commit ce20eff5
      
       upstream.
      
      IRQ domain alloc function should return zero on success. Non-zero value
      indicates failure.
      
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Fixes: fcc392d5
      
       ("irqchip/armada-370-xp: Use the generic MSI infrastructure")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211125130057.26705-1-pali@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97912b97
    • Billy Tsai's avatar
      irqchip/aspeed-scu: Replace update_bits with write_bits. · f2675399
      Billy Tsai authored
      commit 89583896 upstream.
      
      The interrupt status bits are cleared by writing 1, we should force a
      write to clear the interrupt without checking if the value has changed.
      
      Fixes: 04f60590
      
       ("irqchip: Add Aspeed SCU interrupt controller")
      Signed-off-by: default avatarBilly Tsai <billy_tsai@aspeedtech.com>
      Reviewed-by: default avatarJoel Stanley <joel@jms.id.au>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211124094348.11621-1-billy_tsai@aspeedtech.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2675399
    • Kelly Devilliv's avatar
      csky: fix typo of fpu config macro · e18f3e04
      Kelly Devilliv authored
      commit a0793fda
      
       upstream.
      
      Fix typo which will cause fpe and privilege exception error.
      
      Signed-off-by: default avatarKelly Devilliv <kelly.devilliv@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGuo Ren <guoren@linux.alibaba.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e18f3e04
    • Loic Poulain's avatar
      bus: mhi: core: Add support for forced PM resume · 47b355f2
      Loic Poulain authored
      commit cab2d3fd upstream.
      
      For whatever reason, some devices like QCA6390, WCN6855 using ath11k
      are not in M3 state during PM resume, but still functional. The
      mhi_pm_resume should then not fail in those cases, and let the higher
      level device specific stack continue resuming process.
      
      Add an API mhi_pm_resume_force(), to force resuming irrespective of the
      current MHI state. This fixes a regression with non functional ath11k WiFi
      after suspend/resume cycle on some machines.
      
      Bug report: https://bugzilla.kernel.org/show_bug.cgi?id=214179
      
      Link: https://lore.kernel.org/regressions/871r5p0x2u.fsf@codeaurora.org/
      Fixes: 020d3b26
      
       ("bus: mhi: Early MHI resume failure in non M3 state")
      Cc: stable@vger.kernel.org #5.13
      Reported-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Reported-by: default avatarPengyu Ma <mapengyu@gmail.com>
      Tested-by: default avatarKalle Valo <kvalo@kernel.org>
      Acked-by: default avatarKalle Valo <kvalo@kernel.org>
      Signed-off-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      [mani: Switched to API, added bug report, reported-by tags and CCed stable]
      Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Link: https://lore.kernel.org/r/20211209131633.4168-1-manivannan.sadhasivam@linaro.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      47b355f2
    • Slark Xiao's avatar
      bus: mhi: pci_generic: Fix device recovery failed issue · 7f4b37c7
      Slark Xiao authored
      commit e2022cbe upstream.
      
      For Foxconn T99W175 device(sdx55 platform) in some host platform,
      it would be unavailable once the host execute the err handler.
      
      After checking, it's caused by the delay time too short to
      get a successful reset.
      
      Please see my test evidence as bewlow(BTW, I add some extra test logs
      in function mhi_pci_reset_prepare and mhi_pci_reset_done):
        When MHI_POST_RESET_DELAY_MS equals to 500ms:
         Nov  4 14:30:03 jbd-ThinkEdge kernel: [  146.222477] mhi mhi0: Device MHI is not in valid state
         Nov  4 14:30:03 jbd-ThinkEdge kernel: [  146.222628] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_prepare reset
         Nov  4 14:30:03 jbd-ThinkEdge kernel: [  146.222631] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_prepare mhi_soc_reset
         Nov  4 14:30:03 jbd-ThinkEdge kernel: [  146.222632] mhi mhi0:  mhi_soc_reset write soc to reset
         Nov  4 14:30:05 jbd-ThinkEdge kernel: [  147.839993] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_done
         Nov  4 14:30:05 jbd-ThinkEdge kernel: [  147.902063] mhi-pci-generic 0000:2d:00.0: reset failed
      
        When MHI_POST_RESET_DELAY_MS equals to 1000ms or 1500ms:
         Nov  4 19:07:26 jbd-ThinkEdge kernel: [  157.067857] mhi mhi0: Device MHI is not in valid state
         Nov  4 19:07:26 jbd-ThinkEdge kernel: [  157.068029] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_prepare reset
         Nov  4 19:07:26 jbd-ThinkEdge kernel: [  157.068032] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_prepare mhi_soc_reset
         Nov  4 19:07:26 jbd-ThinkEdge kernel: [  157.068034] mhi mhi0:  mhi_soc_reset write soc to reset
         Nov  4 19:07:29 jbd-ThinkEdge kernel: [  159.607006] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_done
         Nov  4 19:07:29 jbd-ThinkEdge kernel: [  159.607152] mhi mhi0: Requested to power ON
         Nov  4 19:07:51 jbd-ThinkEdge kernel: [  181.302872] mhi mhi0: Failed to reset MHI due to syserr state
         Nov  4 19:07:51 jbd-ThinkEdge kernel: [  181.303011] mhi-pci-generic 0000:2d:00.0: failed to power up MHI controller
      
        When MHI_POST_RESET_DELAY_MS equals to 2000ms:
         Nov  4 17:51:08 jbd-ThinkEdge kernel: [  147.180527] mhi mhi0: Failed to transition from PM state: Linkdown or Error Fatal Detect to: SYS ERROR Process
         Nov  4 17:51:08 jbd-ThinkEdge kernel: [  147.180535] mhi mhi0: Device MHI is not in valid state
         Nov  4 17:51:08 jbd-ThinkEdge kernel: [  147.180722] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_prepare reset
         Nov  4 17:51:08 jbd-ThinkEdge kernel: [  147.180725] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_prepare mhi_soc_reset
         Nov  4 17:51:08 jbd-ThinkEdge kernel: [  147.180727] mhi mhi0:  mhi_soc_reset write soc to reset
         Nov  4 17:51:11 jbd-ThinkEdge kernel: [  150.230787] mhi-pci-generic 0000:2d:00.0: mhi_pci_reset_done
         Nov  4 17:51:11 jbd-ThinkEdge kernel: [  150.230928] mhi mhi0: Requested to power ON
         Nov  4 17:51:11 jbd-ThinkEdge kernel: [  150.231173] mhi mhi0: Power on setup success
         Nov  4 17:51:14 jbd-ThinkEdge kernel: [  153.254747] mhi mhi0: Wait for device to enter SBL or Mission mode
      
      I also tried big data like 3000, and it worked as well. 500ms may not be
      enough for all support mhi device. We shall increase it to 2000ms
      at least.
      
      Link: https://lore.kernel.org/r/20211108113127.3938-1-slark_xiao@163.com
      [mani: massaged commit message little bit, added Fixes tag and CCed stable]
      Fixes: 8ccc3279
      
       ("mhi: pci_generic: Add support for reset")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarManivannan Sadhasivam <mani@kernel.org>
      Signed-off-by: default avatarSlark Xiao <slark_xiao@163.com>
      Signed-off-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Link: https://lore.kernel.org/r/20211126104951.35685-2-manivannan.sadhasivam@linaro.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f4b37c7
    • Ralph Siemsen's avatar
      nvmem: eeprom: at25: fix FRAM byte_len · 5bff8dff
      Ralph Siemsen authored
      commit 9a626577 upstream.
      
      Commit fd307a4a ("nvmem: prepare basics for FRAM support") added
      support for FRAM devices such as the Cypress FM25V. During testing, it
      was found that the FRAM detects properly, however reads and writes fail.
      Upon further investigation, two problem were found in at25_probe() routine.
      
      1) In the case of an FRAM device without platform data, eg.
             fram == true && spi->dev.platform_data == NULL
      the stack local variable "struct spi_eeprom chip" is not initialized
      fully, prior to being copied into at25->chip. The chip.flags field in
      particular can cause problems.
      
      2) The byte_len of FRAM is computed from its ID register, and is stored
      into the stack local "struct spi_eeprom chip" structure. This happens
      after the same structure has been copied into at25->chip. As a result,
      at25->chip.byte_len does not contain the correct length of the device.
      In turn this can cause checks at beginning of at25_ee_read() to fail
      (or equally, it could allow reads beyond the end of the device length).
      
      Fix both of these issues by eliminating the on-stack struct spi_eeprom.
      Instead use the one inside at25_data structure, which starts of zeroed.
      
      Fixes: fd307a4a
      
       ("nvmem: prepare basics for FRAM support")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarRalph Siemsen <ralph.siemsen@linaro.org>
      Link: https://lore.kernel.org/r/20211108181627.645638-1-ralph.siemsen@linaro.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5bff8dff
    • Kai-Heng Feng's avatar
      misc: rtsx: Avoid mangling IRQ during runtime PM · 990bbe35
      Kai-Heng Feng authored
      commit 0edeb899 upstream.
      
      After commit 5b4258f6 ("misc: rtsx: rts5249 support runtime PM"), when the
      rtsx controller is runtime suspended, bring CPUs offline and back online, the
      runtime resume of the controller will fail:
      
      [   47.319391] smpboot: CPU 1 is now offline
      [   47.414140] x86: Booting SMP configuration:
      [   47.414147] smpboot: Booting Node 0 Processor 1 APIC 0x2
      [   47.571334] smpboot: CPU 2 is now offline
      [   47.686055] smpboot: Booting Node 0 Processor 2 APIC 0x4
      [   47.808174] smpboot: CPU 3 is now offline
      [   47.878146] smpboot: Booting Node 0 Processor 3 APIC 0x6
      [   48.003679] smpboot: CPU 4 is now offline
      [   48.086187] smpboot: Booting Node 0 Processor 4 APIC 0x1
      [   48.239627] smpboot: CPU 5 is now offline
      [   48.326059] smpboot: Booting Node 0 Processor 5 APIC 0x3
      [   48.472193] smpboot: CPU 6 is now offline
      [   48.574181] smpboot: Booting Node 0 Processor 6 APIC 0x5
      [   48.743375] smpboot: CPU 7 is now offline
      [   48.838047] smpboot: Booting Node 0 Processor 7 APIC 0x7
      [   48.965447] __common_interrupt: 1.35 No irq handler for vector
      [   51.174065] mmc0: error -110 doing runtime resume
      [   54.978088] I/O error, dev mmcblk0, sector 21479 op 0x1:(WRITE) flags 0x0 phys_seg 11 prio class 0
      [   54.978108] Buffer I/O error on dev mmcblk0p1, logical block 19431, lost async page write
      [   54.978129] Buffer I/O error on dev mmcblk0p1, logical block 19432, lost async page write
      [   54.978134] Buffer I/O error on dev mmcblk0p1, logical block 19433, lost async page write
      [   54.978137] Buffer I/O error on dev mmcblk0p1, logical block 19434, lost async page write
      [   54.978141] Buffer I/O error on dev mmcblk0p1, logical block 19435, lost async page write
      [   54.978145] Buffer I/O error on dev mmcblk0p1, logical block 19436, lost async page write
      [   54.978148] Buffer I/O error on dev mmcblk0p1, logical block 19437, lost async page write
      [   54.978152] Buffer I/O error on dev mmcblk0p1, logical block 19438, lost async page write
      [   54.978155] Buffer I/O error on dev mmcblk0p1, logical block 19439, lost async page write
      [   54.978160] Buffer I/O error on dev mmcblk0p1, logical block 19440, lost async page write
      [   54.978244] mmc0: card aaaa removed
      [   54.978452] FAT-fs (mmcblk0p1): FAT read failed (blocknr 4257)
      
      There's interrupt immediately raised on rtsx_pci_write_register() in
      runtime resume routine, but the IRQ handler hasn't registered yet.
      
      So we can either move rtsx_pci_write_register() after rtsx_pci_acquire_irq(),
      or just stop mangling IRQ on runtime PM. Choose the latter to save some
      CPU cycles.
      
      Fixes: 5b4258f6
      
       ("misc: rtsx: rts5249 support runtime PM")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarKai-Heng Feng <kai.heng.feng@canonical.com>
      BugLink: https://bugs.launchpad.net/bugs/1951784
      Link: https://lore.kernel.org/r/20211126003246.1068770-1-kai.heng.feng@canonical.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      990bbe35
    • Yang Yingliang's avatar
      iio: accel: kxcjk-1013: Fix possible memory leak in probe and remove · 14508fe1
      Yang Yingliang authored
      commit 70c9774e
      
       upstream.
      
      When ACPI type is ACPI_SMO8500, the data->dready_trig will not be set, the
      memory allocated by iio_triggered_buffer_setup() will not be freed, and cause
      memory leak as follows:
      
      unreferenced object 0xffff888009551400 (size 512):
        comm "i2c-SMO8500-125", pid 911, jiffies 4294911787 (age 83.852s)
        hex dump (first 32 bytes):
          02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 20 e2 e5 c0 ff ff ff ff  ........ .......
        backtrace:
          [<0000000041ce75ee>] kmem_cache_alloc_trace+0x16d/0x360
          [<000000000aeb17b0>] iio_kfifo_allocate+0x41/0x130 [kfifo_buf]
          [<000000004b40c1f5>] iio_triggered_buffer_setup_ext+0x2c/0x210 [industrialio_triggered_buffer]
          [<000000004375b15f>] kxcjk1013_probe+0x10c3/0x1d81 [kxcjk_1013]
      
      Fix it by remove data->dready_trig condition in probe and remove.
      
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Fixes: a25691c1
      
       ("iio: accel: kxcjk1013: allow using an external trigger")
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Cc: <Stable@vger.kernel.org>
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20211025124159.2700301-1-yangyingliang@huawei.com
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14508fe1
    • Lars-Peter Clausen's avatar
      iio: ad7768-1: Call iio_trigger_notify_done() on error · 2906867d
      Lars-Peter Clausen authored
      commit 66611464 upstream.
      
      IIO trigger handlers must call iio_trigger_notify_done() when done. This
      must be done even when an error occurred. Otherwise the trigger will be
      seen as busy indefinitely and the trigger handler will never be called
      again.
      
      The ad7768-1 driver neglects to call iio_trigger_notify_done() when there
      is an error reading the converter data. Fix this by making sure that
      iio_trigger_notify_done() is included in the error exit path.
      
      Fixes: a5f8c7da
      
       ("iio: adc: Add AD7768-1 ADC basic support")
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Link: https://lore.kernel.org/r/20211101144055.13858-2-lars@metafoo.de
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2906867d
    • Evgeny Boger's avatar
      iio: adc: axp20x_adc: fix charging current reporting on AXP22x · b3a4c57a
      Evgeny Boger authored
      commit 92beafb7 upstream.
      
      Both the charging and discharging currents on AXP22x are stored as
      12-bit integers, in accordance with the datasheet.
      It's also confirmed by vendor BSP (axp20x_adc.c:axp22_icharge_to_mA).
      
      The scale factor of 0.5 is never mentioned in datasheet, nor in the
      vendor source code. I think it was here to compensate for
      erroneous addition bit in register width.
      
      Tested on custom A40i+AXP221s board with external ammeter as
      a reference.
      
      Fixes: 0e34d5de
      
       ("iio: adc: add support for X-Powers AXP20X and AXP22X PMICs ADCs")
      Signed-off-by: default avatarEvgeny Boger <boger@wirenboard.com>
      Acked-by: default avatarChen-Yu Tsai <wens@csie.org>
      Link: https://lore.kernel.org/r/20211116213746.264378-1-boger@wirenboard.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3a4c57a
    • Fabrice Gasnier's avatar
      iio: adc: stm32: fix a current leak by resetting pcsel before disabling vdda · 41d241ad
      Fabrice Gasnier authored
      commit f711f28e upstream.
      
      Some I/Os are connected to ADC input channels, when the corresponding bit
      in PCSEL register are set on STM32H7 and STM32MP15. This is done in the
      prepare routine of stm32-adc driver.
      There are constraints here, as PCSEL shouldn't be set when VDDA supply
      is disabled. Enabling/disabling of VDDA supply in done via stm32-adc-core
      runtime PM routines (before/after ADC is enabled/disabled).
      
      Currently, PCSEL remains set when disabling ADC. Later on, PM runtime
      can disable the VDDA supply. This creates some conditions on I/Os that
      can start to leak current.
      So PCSEL needs to be cleared when disabling the ADC.
      
      Fixes: 95e339b6
      
       ("iio: adc: stm32: add support for STM32H7")
      Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@foss.st.com>
      Reviewed-by: default avatarOlivier Moysan <olivier.moysan@foss.st.com>
      Link: https://lore.kernel.org/r/1634905169-23762-1-git-send-email-fabrice.gasnier@foss.st.com
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41d241ad
    • Gwendal Grignou's avatar
      iio: at91-sama5d2: Fix incorrect sign extension · 4071943a
      Gwendal Grignou authored
      commit 652e7df4 upstream.
      
      Use scan_type when processing raw data which also fixes that the sign
      extension was from the wrong bit.
      
      Use channel definition as root of trust and replace constant
      when reading elements directly using the raw sysfs attributes.
      
      Fixes: 6794e23f
      
       ("iio: adc: at91-sama5d2_adc: add support for oversampling resolution")
      Signed-off-by: default avatarGwendal Grignou <gwendal@chromium.org>
      Reviewed-by: default avatarEugen Hristev <eugen.hristev@microchip.com>
      Cc: <Stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20211104082413.3681212-9-gwendal@chromium.org
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4071943a
    • Lars-Peter Clausen's avatar
      iio: dln2: Check return value of devm_iio_trigger_register() · a862c731
      Lars-Peter Clausen authored
      commit 90751fb9 upstream.
      
      Registering a trigger can fail and the return value of
      devm_iio_trigger_register() must be checked. Otherwise undefined behavior
      can occur when the trigger is used.
      
      Fixes: 7c0299e8
      
       ("iio: adc: Add support for DLN2 ADC")
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Link: https://lore.kernel.org/r/20211101133043.6974-1-lars@metafoo.de
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a862c731
    • Noralf Trønnes's avatar
      iio: dln2-adc: Fix lockdep complaint · 9b4e3b80
      Noralf Trønnes authored
      commit 59f92868 upstream.
      
      When reading the voltage:
      
      $ cat /sys/bus/iio/devices/iio\:device0/in_voltage0_raw
      
      Lockdep complains:
      
      [  153.910616] ======================================================
      [  153.916918] WARNING: possible circular locking dependency detected
      [  153.923221] 5.14.0+ #5 Not tainted
      [  153.926692] ------------------------------------------------------
      [  153.932992] cat/717 is trying to acquire lock:
      [  153.937525] c2585358 (&indio_dev->mlock){+.+.}-{3:3}, at: iio_device_claim_direct_mode+0x28/0x44
      [  153.946541]
                     but task is already holding lock:
      [  153.952487] c2585860 (&dln2->mutex){+.+.}-{3:3}, at: dln2_adc_read_raw+0x94/0x2bc [dln2_adc]
      [  153.961152]
                     which lock already depends on the new lock.
      
      Fix this by not calling into the iio core underneath the dln2->mutex lock.
      
      Fixes: 7c0299e8
      
       ("iio: adc: Add support for DLN2 ADC")
      Cc: Jack Andersen <jackoalan@gmail.com>
      Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
      Link: https://lore.kernel.org/r/20211018113731.25723-1-noralf@tronnes.org
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9b4e3b80
    • Lars-Peter Clausen's avatar
      iio: itg3200: Call iio_trigger_notify_done() on error · 363e1286
      Lars-Peter Clausen authored
      commit 67fe2958 upstream.
      
      IIO trigger handlers must call iio_trigger_notify_done() when done. This
      must be done even when an error occurred. Otherwise the trigger will be
      seen as busy indefinitely and the trigger handler will never be called
      again.
      
      The itg3200 driver neglects to call iio_trigger_notify_done() when there is
      an error reading the gyro data. Fix this by making sure that
      iio_trigger_notify_done() is included in the error exit path.
      
      Fixes: 9dbf091d
      
       ("iio: gyro: Add itg3200")
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Link: https://lore.kernel.org/r/20211101144055.13858-1-lars@metafoo.de
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      363e1286
    • Lars-Peter Clausen's avatar
      iio: kxsd9: Don't return error code in trigger handler · e4b600ac
      Lars-Peter Clausen authored
      commit 45febe0d upstream.
      
      IIO trigger handlers need to return one of the irqreturn_t values.
      Returning an error code is not supported.
      
      The kxsd9 interrupt handler returns an error code if reading the data
      registers fails. In addition when exiting due to an error the trigger
      handler does not call `iio_trigger_notify_done()`. Which when not done
      keeps the triggered disabled forever.
      
      Modify the code so that the function returns a valid irqreturn_t value as
      well as calling `iio_trigger_notify_done()` on all exit paths.
      
      Since we can't return the error code make sure to at least log it as part
      of the error message.
      
      Fixes: 0427a106
      
       ("iio: accel: kxsd9: Add triggered buffer handling")
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Link: https://lore.kernel.org/r/20211024171251.22896-2-lars@metafoo.de
      Cc: <Stable@vger.kernel.org>
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e4b600ac