21 Jul, 2021

1 commit

  • The driver core ignores the return value of this callback because there
    is only little it can do when a device disappears.

    This is the final bit of a long lasting cleanup quest where several
    buses were converted to also return void from their remove callback.
    Additionally some resource leaks were fixed that were caused by drivers
    returning an error code in the expectation that the driver won't go
    away.

    With struct bus_type::remove returning void it's prevented that newly
    implemented buses return an ignored error code and so don't anticipate
    wrong expectations for driver authors.

    Reviewed-by: Tom Rix (For fpga)
    Reviewed-by: Mathieu Poirier
    Reviewed-by: Cornelia Huck (For drivers/s390 and drivers/vfio)
    Acked-by: Russell King (Oracle) (For ARM, Amba and related parts)
    Acked-by: Mark Brown
    Acked-by: Chen-Yu Tsai (for sunxi-rsb)
    Acked-by: Pali Rohár
    Acked-by: Mauro Carvalho Chehab (for media)
    Acked-by: Hans de Goede (For drivers/platform)
    Acked-by: Alexandre Belloni
    Acked-By: Vinod Koul
    Acked-by: Juergen Gross (For xen)
    Acked-by: Lee Jones (For mfd)
    Acked-by: Johannes Thumshirn (For mcb)
    Acked-by: Johan Hovold
    Acked-by: Srinivas Kandagatla (For slimbus)
    Acked-by: Kirti Wankhede (For vfio)
    Acked-by: Maximilian Luz
    Acked-by: Heikki Krogerus (For ulpi and typec)
    Acked-by: Samuel Iglesias Gonsálvez (For ipack)
    Acked-by: Geoff Levand (For ps3)
    Acked-by: Yehezkel Bernat (For thunderbolt)
    Acked-by: Alexander Shishkin (For intel_th)
    Acked-by: Dominik Brodowski (For pcmcia)
    Acked-by: Rafael J. Wysocki (For ACPI)
    Acked-by: Bjorn Andersson (rpmsg and apr)
    Acked-by: Srinivas Pandruvada (For intel-ish-hid)
    Acked-by: Dan Williams (For CXL, DAX, and NVDIMM)
    Acked-by: William Breathitt Gray (For isa)
    Acked-by: Stefan Richter (For firewire)
    Acked-by: Benjamin Tissoires (For hid)
    Acked-by: Thorsten Scherer (For siox)
    Acked-by: Sven Van Asbroeck (For anybuss)
    Acked-by: Ulf Hansson (For MMC)
    Acked-by: Wolfram Sang # for I2C
    Acked-by: Sudeep Holla
    Acked-by: Geert Uytterhoeven
    Acked-by: Dmitry Torokhov
    Acked-by: Finn Thain
    Signed-off-by: Uwe Kleine-König
    Link: https://lore.kernel.org/r/20210713193522.1770306-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Uwe Kleine-König
     

14 May, 2021

2 commits

  • In case create_workqueue() fails, release all resources and return -ENOMEM
    to caller to avoid potential NULL pointer deref later. Move up the
    create_workequeue() call to return early and avoid unwinding the call to
    riocm_rx_fill().

    Cc: Alexandre Bounine
    Cc: Matt Porter
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: stable
    Signed-off-by: Anirudh Rayabharam
    Link: https://lore.kernel.org/r/20210503115736.2104747-46-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Anirudh Rayabharam
     
  • This reverts commit 23015b22e47c5409620b1726a677d69e5cd032ba.

    Because of recent interactions with developers from @umn.edu, all
    commits from them have been recently re-reviewed to ensure if they were
    correct or not.

    Upon review, this commit was found to be incorrect for the reasons
    below, so it must be reverted. It will be fixed up "correctly" in a
    later kernel change.

    The original commit has a memory leak on the error path here, it does
    not clean up everything properly.

    Cc: Kangjie Lu
    Cc: Alexandre Bounine
    Cc: Matt Porter
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Fixes: 23015b22e47c ("rapidio: fix a NULL pointer dereference when create_workqueue() fails")
    Cc: stable
    Link: https://lore.kernel.org/r/20210503115736.2104747-45-gregkh@linuxfoundation.org
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

22 Jan, 2021

1 commit


16 Dec, 2020

1 commit

  • The functions rio_get_asm() and rio_get_device() are globally exported
    but have almost no users in tree. The only user is rio_init_mports()
    which invokes it via rio_init().

    rio_init() iterates over every registered device and invokes
    rio_fixup_device(). It looks like a fixup function which should perform a
    "change" to the device but does nothing. It has been like this since its
    introduction in commit 394b701ce4fbf ("[PATCH] RapidIO support: core
    base") which was merged into v2.6.15-rc1.

    Remove rio_init() because the performed fixup function
    (rio_fixup_device()) does nothing. Remove rio_get_asm() and
    rio_get_device() which have no callers now.

    Link: https://lkml.kernel.org/r/20201116170004.420143-1-bigeasy@linutronix.de
    Signed-off-by: Sebastian Andrzej Siewior
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sebastian Andrzej Siewior
     

17 Oct, 2020

2 commits

  • rio_mport_add_riodev() misses to call put_device() when the device already
    exists. Add the missed function call to fix it.

    Fixes: e8de370188d0 ("rapidio: add mport char device driver")
    Signed-off-by: Jing Xiangfeng
    Signed-off-by: Andrew Morton
    Reviewed-by: Dan Carpenter
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Cc: Gustavo A. R. Silva
    Cc: John Hubbard
    Cc: Kees Cook
    Cc: Madhuparna Bhowmik
    Link: https://lkml.kernel.org/r/20200922072525.42330-1-jingxiangfeng@huawei.com
    Signed-off-by: Linus Torvalds

    Jing Xiangfeng
     
  • rio_dma_transfer() attempts to clamp the return value of
    pin_user_pages_fast() to be >= 0. However, the attempt fails because
    nr_pages is overridden a few lines later, and restored to the undesirable
    -ERRNO value.

    The return value is ultimately stored in nr_pages, which in turn is passed
    to unpin_user_pages(), which expects nr_pages >= 0, else, disaster.

    Fix this by fixing the nesting of the assignment to nr_pages: nr_pages
    should be clamped to zero if pin_user_pages_fast() returns -ERRNO, or set
    to the return value of pin_user_pages_fast(), otherwise.

    [jhubbard@nvidia.com: new changelog]

    Fixes: e8de370188d09 ("rapidio: add mport char device driver")
    Signed-off-by: Souptick Joarder
    Signed-off-by: Andrew Morton
    Reviewed-by: Ira Weiny
    Reviewed-by: John Hubbard
    Cc: Matthew Wilcox
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Cc: Gustavo A. R. Silva
    Cc: Madhuparna Bhowmik
    Cc: Dan Carpenter
    Link: https://lkml.kernel.org/r/1600227737-20785-1-git-send-email-jrdr.linux@gmail.com
    Signed-off-by: Linus Torvalds

    Souptick Joarder
     

06 Sep, 2020

1 commit


24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

13 Aug, 2020

3 commits

  • Use array_size() helper instead of the open-coded version in
    copy_{from,to}_user(). These sorts of multiplication factors need to be
    wrapped in array_size().

    This issue was found with the help of Coccinelle and, audited and fixed
    manually.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Andrew Morton
    Reviewed-by: Kees Cook
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Link: http://lkml.kernel.org/r/20200616183050.GA31840@embeddedor
    Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     
  • Make use of the struct_size() helper instead of an open-coded version in
    order to avoid any potential type mistakes.

    Also, while there, use the preferred form for passing a size of a struct.
    The alternative form where struct name is spelled out hurts readability
    and introduces an opportunity for a bug when the pointer variable type is
    changed but the corresponding sizeof that is passed as argument is not.

    This issue was found with the help of Coccinelle and, audited and fixed
    manually.

    Addresses KSPP ID: https://github.com/KSPP/linux/issues/83

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Andrew Morton
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Link: http://lkml.kernel.org/r/20200619170445.GA22641@embeddedor
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     
  • Make use of the struct_size() helper instead of an open-coded version in
    order to avoid any potential type mistakes.

    This issue was found with the help of Coccinelle and, audited and fixed
    manually.

    Addresses KSPP ID: https://github.com/KSPP/linux/issues/83

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Andrew Morton
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Link: http://lkml.kernel.org/r/20200619170843.GA24923@embeddedor
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     

16 Jun, 2020

1 commit

  • There is a regular need in the kernel to provide a way to declare having a
    dynamically sized set of trailing elements in a structure. Kernel code should
    always use “flexible array members”[1] for these cases. The older style of
    one-element or zero-length arrays should no longer be used[2].

    [1] https://en.wikipedia.org/wiki/Flexible_array_member
    [2] https://github.com/KSPP/linux/issues/21

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

14 Jun, 2020

1 commit

  • Since commit 84af7a6194e4 ("checkpatch: kconfig: prefer 'help' over
    '---help---'"), the number of '---help---' has been gradually
    decreasing, but there are still more than 2400 instances.

    This commit finishes the conversion. While I touched the lines,
    I also fixed the indentation.

    There are a variety of indentation styles found.

    a) 4 spaces + '---help---'
    b) 7 spaces + '---help---'
    c) 8 spaces + '---help---'
    d) 1 space + 1 tab + '---help---'
    e) 1 tab + '---help---' (correct indentation)
    f) 1 tab + 1 space + '---help---'
    g) 1 tab + 2 spaces + '---help---'

    In order to convert all of them to 1 tab + 'help', I ran the
    following commend:

    $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

05 Jun, 2020

2 commits

  • This code was using get_user_pages_fast(), in a "Case 2" scenario
    (DMA/RDMA), using the categorization from [1]. That means that it's time
    to convert the get_user_pages_fast() + put_page() calls to
    pin_user_pages_fast() + unpin_user_pages() calls.

    There is some helpful background in [2]: basically, this is a small
    part of fixing a long-standing disconnect between pinning pages, and
    file systems' use of those pages.

    [1] Documentation/core-api/pin_user_pages.rst

    [2] "Explicit pinning of user-space pages":
    https://lwn.net/Articles/807108/

    Signed-off-by: John Hubbard
    Signed-off-by: Andrew Morton
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Cc: Sumit Semwal
    Cc: Dan Carpenter
    Link: http://lkml.kernel.org/r/20200517235620.205225-3-jhubbard@nvidia.com
    Signed-off-by: Linus Torvalds

    John Hubbard
     
  • Fields of md(mport_dev) are set after cdev_device_add(). However, the
    file operation callbacks can be called after cdev_device_add() and
    therefore accesses to fields of md in the callbacks can race with the rest
    of the mport_cdev_add() function.

    One such example is INIT_LIST_HEAD(&md->portwrites) in mport_cdev_add(),
    the list is initialised after cdev_device_add(). This can race with
    list_add_tail(&pw_filter->md_node,&md->portwrites) in
    rio_mport_add_pw_filter() which is called by unlocked_ioctl.

    To avoid such data races use cdev_device_add() after initializing md.

    Found by Linux Driver Verification project (linuxtesting.org).

    Signed-off-by: Madhuparna Bhowmik
    Signed-off-by: Andrew Morton
    Acked-by: Alexandre Bounine
    Cc: Matt Porter
    Cc: Dan Carpenter
    Cc: Mike Marshall
    Cc: Thomas Gleixner
    Cc: Ira Weiny
    Cc: Allison Randal
    Cc: Pavel Andrianov
    Link: http://lkml.kernel.org/r/20200426112950.1803-1-madhuparnabhowmik10@gmail.com
    Signed-off-by: Linus Torvalds

    Madhuparna Bhowmik
     

24 May, 2020

1 commit

  • In the case of get_user_pages_fast() returning fewer pages than
    requested, rio_dma_transfer() does not quite do the right thing. It
    attempts to release all the pages that were requested, rather than just
    the pages that were pinned.

    Fix the error handling so that only the pages that were successfully
    pinned are released.

    Fixes: e8de370188d0 ("rapidio: add mport char device driver")
    Signed-off-by: John Hubbard
    Signed-off-by: Andrew Morton
    Reviewed-by: Andrew Morton
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Cc: Sumit Semwal
    Cc: Dan Carpenter
    Cc:
    Link: http://lkml.kernel.org/r/20200517235620.205225-2-jhubbard@nvidia.com
    Signed-off-by: Linus Torvalds

    John Hubbard
     

05 Dec, 2019

2 commits

  • Include for the missing declarations of functions
    exported from this file. Fixes the following sparse warnings:

    drivers/rapidio/rio-access.c:59:1: warning: symbol '__rio_local_read_config_8' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:60:1: warning: symbol '__rio_local_read_config_16' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:61:1: warning: symbol '__rio_local_read_config_32' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:62:1: warning: symbol '__rio_local_write_config_8' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:63:1: warning: symbol '__rio_local_write_config_16' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:64:1: warning: symbol '__rio_local_write_config_32' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:112:1: warning: symbol 'rio_mport_read_config_8' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:113:1: warning: symbol 'rio_mport_read_config_16' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:114:1: warning: symbol 'rio_mport_read_config_32' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:115:1: warning: symbol 'rio_mport_write_config_8' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:116:1: warning: symbol 'rio_mport_write_config_16' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:117:1: warning: symbol 'rio_mport_write_config_32' was not declared. Should it be static?
    drivers/rapidio/rio-access.c:136:5: warning: symbol 'rio_mport_send_doorbell' was not declared. Should it be static?

    Link: http://lkml.kernel.org/r/20191017115103.684-1-ben.dooks@codethink.co.uk
    Signed-off-by: Ben Dooks
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ben Dooks (Codethink)
     
  • Include for the missing declarations of functions
    exported from this file. Fixes the following sparse warnings:

    drivers/rapidio/rio-driver.c:53:16: warning: symbol 'rio_dev_get' was not declared. Should it be static?
    drivers/rapidio/rio-driver.c:70:6: warning: symbol 'rio_dev_put' was not declared. Should it be static?
    drivers/rapidio/rio-driver.c:150:5: warning: symbol 'rio_register_driver' was not declared. Should it be static?
    drivers/rapidio/rio-driver.c:169:6: warning: symbol 'rio_unregister_driver' was not declared. Should it be static?

    Link: http://lkml.kernel.org/r/20191017114923.10888-1-ben.dooks@codethink.co.uk
    Signed-off-by: Ben Dooks
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ben Dooks (Codethink)
     

14 Oct, 2019

1 commit

  • Code that iterates over all standard PCI BARs typically uses
    PCI_STD_RESOURCE_END. However, that requires the unusual test
    "i < PCI_STD_NUM_BARS".

    Add a definition for PCI_STD_NUM_BARS and change loops to use the more
    idiomatic C style to help avoid fencepost errors.

    Link: https://lore.kernel.org/r/20190927234026.23342-1-efremov@linux.com
    Link: https://lore.kernel.org/r/20190927234308.23935-1-efremov@linux.com
    Link: https://lore.kernel.org/r/20190916204158.6889-3-efremov@linux.com
    Signed-off-by: Denis Efremov
    Signed-off-by: Bjorn Helgaas
    Acked-by: Sebastian Ott # arch/s390/
    Acked-by: Bartlomiej Zolnierkiewicz # video/fbdev/
    Acked-by: Gustavo Pimentel # pci/controller/dwc/
    Acked-by: Jack Wang # scsi/pm8001/
    Acked-by: Martin K. Petersen # scsi/pm8001/
    Acked-by: Ulf Hansson # memstick/

    Denis Efremov
     

17 Jul, 2019

2 commits

  • Merge more updates from Andrew Morton:
    "VM:
    - z3fold fixes and enhancements by Henry Burns and Vitaly Wool

    - more accurate reclaimed slab caches calculations by Yafang Shao

    - fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by
    Christoph Hellwig

    - !CONFIG_MMU fixes by Christoph Hellwig

    - new novmcoredd parameter to omit device dumps from vmcore, by
    Kairui Song

    - new test_meminit module for testing heap and pagealloc
    initialization, by Alexander Potapenko

    - ioremap improvements for huge mappings, by Anshuman Khandual

    - generalize kprobe page fault handling, by Anshuman Khandual

    - device-dax hotplug fixes and improvements, by Pavel Tatashin

    - enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V

    - add pte_devmap() support for arm64, by Robin Murphy

    - unify locked_vm accounting with a helper, by Daniel Jordan

    - several misc fixes

    core/lib:
    - new typeof_member() macro including some users, by Alexey Dobriyan

    - make BIT() and GENMASK() available in asm, by Masahiro Yamada

    - changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better
    code generation, by Alexey Dobriyan

    - rbtree code size optimizations, by Michel Lespinasse

    - convert struct pid count to refcount_t, by Joel Fernandes

    get_maintainer.pl:
    - add --no-moderated switch to skip moderated ML's, by Joe Perches

    misc:
    - ptrace PTRACE_GET_SYSCALL_INFO interface

    - coda updates

    - gdb scripts, various"

    [ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ]

    * emailed patches from Andrew Morton : (100 commits)
    fs/select.c: use struct_size() in kmalloc()
    mm: add account_locked_vm utility function
    arm64: mm: implement pte_devmap support
    mm: introduce ARCH_HAS_PTE_DEVMAP
    mm: clean up is_device_*_page() definitions
    mm/mmap: move common defines to mman-common.h
    mm: move MAP_SYNC to asm-generic/mman-common.h
    device-dax: "Hotremove" persistent memory that is used like normal RAM
    mm/hotplug: make remove_memory() interface usable
    device-dax: fix memory and resource leak if hotplug fails
    include/linux/lz4.h: fix spelling and copy-paste errors in documentation
    ipc/mqueue.c: only perform resource calculation if user valid
    include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures
    scripts/gdb: add helpers to find and list devices
    scripts/gdb: add lx-genpd-summary command
    drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl
    kernel/pid.c: convert struct pid count to refcount_t
    drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings
    select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining()
    select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR
    ...

    Linus Torvalds
     
  • The dev_info.name[] array has space for RIO_MAX_DEVNAME_SZ + 1
    characters. But the problem here is that we don't ensure that the user
    put a NUL terminator on the end of the string. It could lead to an out
    of bounds read.

    Link: http://lkml.kernel.org/r/20190529110601.GB19119@mwanda
    Fixes: e8de370188d0 ("rapidio: add mport char device driver")
    Signed-off-by: Dan Carpenter
    Acked-by: Alexandre Bounine
    Cc: Ira Weiny
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Carpenter
     

15 Jul, 2019

2 commits

  • This is actually a subsystem description, with contains both
    kAPI and uAPI.

    While it should ideally be slplit, let's place it at driver-api,
    as most things are related to kAPI and driver-specific info.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     
  • Rename the rapidio documentation files to ReST, add an
    index for them and adjust in order to produce a nice html
    output via the Sphinx build system.

    At its new index.rst, let's add a :orphan: while this is not linked to
    the main index.rst file, in order to avoid build warnings.

    Signed-off-by: Mauro Carvalho Chehab

    Mauro Carvalho Chehab
     

31 May, 2019

3 commits

  • Based on 3 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version [author] [kishon] [vijay] [abraham]
    [i] [kishon]@[ti] [com] this program is distributed in the hope that
    it will be useful but without any warranty without even the implied
    warranty of merchantability or fitness for a particular purpose see
    the gnu general public license for more details

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version [author] [graeme] [gregory]
    [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i]
    [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema]
    [hk] [hemahk]@[ti] [com] this program is distributed in the hope
    that it will be useful but without any warranty without even the
    implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1105 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

2 commits

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details the full
    gnu general public license is included in this distribution in the
    file called copying

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 9 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Steve Winslow
    Reviewed-by: Kate Stewart
    Reviewed-by: Jilayne Lovejoy
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190519154041.244154651@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • Add SPDX license identifiers to all Make/Kconfig files which:

    - Have no license information of any form

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

15 May, 2019

2 commits

  • In case create_workqueue fails, the fix releases resources and returns
    -ENOMEM to avoid NULL pointer dereference.

    Signed-off-by: Kangjie Lu
    Acked-by: Alexandre Bounine
    Cc: Matt Porter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kangjie Lu
     
  • To facilitate additional options to get_user_pages_fast() change the
    singular write parameter to be gup_flags.

    This patch does not change any functionality. New functionality will
    follow in subsequent patches.

    Some of the get_user_pages_fast() call sites were unchanged because they
    already passed FOLL_WRITE or 0 for the write parameter.

    NOTE: It was suggested to change the ordering of the get_user_pages_fast()
    arguments to ensure that callers were converted. This breaks the current
    GUP call site convention of having the returned pages be the final
    parameter. So the suggestion was rejected.

    Link: http://lkml.kernel.org/r/20190328084422.29911-4-ira.weiny@intel.com
    Link: http://lkml.kernel.org/r/20190317183438.2057-4-ira.weiny@intel.com
    Signed-off-by: Ira Weiny
    Reviewed-by: Mike Marshall
    Cc: Aneesh Kumar K.V
    Cc: Benjamin Herrenschmidt
    Cc: Borislav Petkov
    Cc: Dan Williams
    Cc: "David S. Miller"
    Cc: Heiko Carstens
    Cc: Ingo Molnar
    Cc: James Hogan
    Cc: Jason Gunthorpe
    Cc: John Hubbard
    Cc: "Kirill A. Shutemov"
    Cc: Martin Schwidefsky
    Cc: Michal Hocko
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Cc: Ralf Baechle
    Cc: Rich Felker
    Cc: Thomas Gleixner
    Cc: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ira Weiny
     

08 Mar, 2019

2 commits

  • In preparation for enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    This patch fixes the following warning:

    drivers/rapidio/devices/rio_mport_cdev.c: In function `mport_release_mapping':
    drivers/rapidio/devices/rio_mport_cdev.c:2151:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
    rio_unmap_inb_region(mport, map->phys_addr);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    CC drivers/regulator/fixed-helper.o
    CC drivers/pinctrl/stm32/pinctrl-stm32f429.o
    drivers/rapidio/devices/rio_mport_cdev.c:2152:2: note: here
    case MAP_DMA:
    ^~~~

    Warning level 3 was used: -Wimplicit-fallthrough=3

    This patch is part of the ongoing efforts to enable
    -Wimplicit-fallthrough.

    Link: http://lkml.kernel.org/r/20190212175014.GA14326@embeddedor
    Signed-off-by: Gustavo A. R. Silva
    Acked-by: Alexandre Bounine
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Gustavo A. R. Silva
     
  • If riocm_get_channel() fails, then we should just return -EINVAL.
    Calling riocm_put_channel() will trigger a NULL dereference and
    generally we should call put() if the get() didn't succeed.

    Link: http://lkml.kernel.org/r/20190110130230.GB27017@kadam
    Fixes: b6e8d4aa1110 ("rapidio: add RapidIO channelized messaging driver")
    Signed-off-by: Dan Carpenter
    Reviewed-by: Andrew Morton
    Cc: Matt Porter
    Cc: Alexandre Bounine
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Dan Carpenter
     

22 Jan, 2019

1 commit


08 Jan, 2019

1 commit

  • We already need to zero out memory for dma_alloc_coherent(), as such
    using dma_zalloc_coherent() is superflous. Phase it out.

    This change was generated with the following Coccinelle SmPL patch:

    @ replace_dma_zalloc_coherent @
    expression dev, size, data, handle, flags;
    @@

    -dma_zalloc_coherent(dev, size, handle, flags)
    +dma_alloc_coherent(dev, size, handle, flags)

    Suggested-by: Christoph Hellwig
    Signed-off-by: Luis Chamberlain
    [hch: re-ran the script on the latest tree]
    Signed-off-by: Christoph Hellwig

    Luis Chamberlain
     

23 Nov, 2018

1 commit

  • There is no good reason to duplicate the RAPIDIO menu in various
    architectures. Instead provide a selectable HAVE_RAPIDIO symbol
    that indicates native availability of RAPIDIO support and the handle
    the rest in drivers/pci. This also means we now provide support
    for PCI(e) to Rapidio bridges for every architecture instead of a
    limited subset.

    Signed-off-by: Christoph Hellwig
    Acked-by: Thomas Gleixner
    Acked-by: Paul Burton
    Signed-off-by: Masahiro Yamada

    Christoph Hellwig
     

23 Aug, 2018

1 commit

  • Pointer md is being assigned but is never used hence it is redundant and
    can be removed.

    Cleans up clang warning:
    warning: variable 'md' set but not used [-Wunused-but-set-variable]

    Link: http://lkml.kernel.org/r/20180711082346.5223-1-colin.king@canonical.com
    Signed-off-by: Colin Ian King
    Acked-by: Alexandre Bounine
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Colin Ian King
     

13 Jun, 2018

2 commits

  • The vmalloc() function has no 2-factor argument form, so multiplication
    factors need to be wrapped in array_size(). This patch replaces cases of:

    vmalloc(a * b)

    with:
    vmalloc(array_size(a, b))

    as well as handling cases of:

    vmalloc(a * b * c)

    with:

    vmalloc(array3_size(a, b, c))

    This does, however, attempt to ignore constant size factors like:

    vmalloc(4 * 1024)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    vmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    vmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    vmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_ID
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_ID
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    vmalloc(
    - SIZE * COUNT
    + array_size(COUNT, SIZE)
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    vmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    vmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    vmalloc(C1 * C2 * C3, ...)
    |
    vmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants.
    @@
    expression E1, E2;
    constant C1, C2;
    @@

    (
    vmalloc(C1 * C2, ...)
    |
    vmalloc(
    - E1 * E2
    + array_size(E1, E2)
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     
  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

21 Apr, 2018

1 commit

  • Some of the mport_dma_req structure members were initialized late
    inside the do_dma_request() function, just before submitting the
    request to the dma engine. But we have some error branches before
    that. In case of such an error, the code would return on the error
    path and trigger the calling of dma_req_free() with a req structure
    which is not completely initialized. This causes a NULL pointer
    dereference in dma_req_free().

    This patch fixes these error branches by making sure that all
    necessary mport_dma_req structure members are initialized in
    rio_dma_transfer() immediately after the request structure gets
    allocated.

    Link: http://lkml.kernel.org/r/20180412150605.GA31409@nokia.com
    Fixes: bbd876adb8c72 ("rapidio: use a reference count for struct mport_dma_req")
    Signed-off-by: Ioan Nicu
    Tested-by: Alexander Sverdlin
    Acked-by: Alexandre Bounine
    Cc: Barry Wood
    Cc: Matt Porter
    Cc: Christophe JAILLET
    Cc: Logan Gunthorpe
    Cc: Chris Wilson
    Cc: Tvrtko Ursulin
    Cc: Frank Kunz
    Cc: [4.6+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ioan Nicu