22 May, 2023

1 commit

  • After commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new()
    call-back type"), all drivers being converted to .probe_new() and then
    03c835f498b5 ("i2c: Switch .probe() to not take an id parameter")
    convert back to (the new) .probe() to be able to eventually drop
    .probe_new() from struct i2c_driver.

    Signed-off-by: Uwe Kleine-König
    Reviewed-by: Luca Ceresoli
    Signed-off-by: David S. Miller

    Uwe Kleine-König
     

17 Mar, 2023

2 commits


30 Nov, 2022

1 commit


24 Nov, 2022

1 commit


21 Nov, 2022

1 commit

  • nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb
    should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send()
    won't free the skb when it failed for the test_bit(). Free the skb when
    test_bit() failed.

    Fixes: b5b3e23e4cac ("NFC: nfcmrvl: add i2c driver")
    Signed-off-by: Shang XiaoJing
    Suggested-by: Pavel Machek
    Signed-off-by: David S. Miller

    Shang XiaoJing
     

31 Oct, 2022

1 commit

  • nfcmrvl_i2c_nci_send() will be called by nfcmrvl_nci_send(), and skb
    should be freed in nfcmrvl_i2c_nci_send(). However, nfcmrvl_nci_send()
    will only free skb when i2c_master_send() return >=0, which means skb
    will memleak when i2c_master_send() failed. Free skb no matter whether
    i2c_master_send() succeeds.

    Fixes: b5b3e23e4cac ("NFC: nfcmrvl: add i2c driver")
    Signed-off-by: Shang XiaoJing
    Signed-off-by: David S. Miller

    Shang XiaoJing
     

16 Aug, 2022

1 commit

  • The value returned by an i2c driver's remove function is mostly ignored.
    (Only an error message is printed if the value is non-zero that the
    error is ignored.)

    So change the prototype of the remove function to return no value. This
    way driver authors are not tempted to assume that passing an error to
    the upper layer is a good idea. All drivers are adapted accordingly.
    There is no intended change of behaviour, all callbacks were prepared to
    return 0 before.

    Reviewed-by: Peter Senna Tschudin
    Reviewed-by: Jeremy Kerr
    Reviewed-by: Benjamin Mugnier
    Reviewed-by: Javier Martinez Canillas
    Reviewed-by: Crt Mori
    Reviewed-by: Heikki Krogerus
    Acked-by: Greg Kroah-Hartman
    Acked-by: Marek Behún # for leds-turris-omnia
    Acked-by: Andy Shevchenko
    Reviewed-by: Petr Machata # for mlxsw
    Reviewed-by: Maximilian Luz # for surface3_power
    Acked-by: Srinivas Pandruvada # for bmc150-accel-i2c + kxcjk-1013
    Reviewed-by: Hans Verkuil # for media/* + staging/media/*
    Acked-by: Miguel Ojeda # for auxdisplay/ht16k33 + auxdisplay/lcd2s
    Reviewed-by: Luca Ceresoli # for versaclock5
    Reviewed-by: Ajay Gupta # for ucsi_ccg
    Acked-by: Jonathan Cameron # for iio
    Acked-by: Peter Rosin # for i2c-mux-*, max9860
    Acked-by: Adrien Grassein # for lontium-lt8912b
    Reviewed-by: Jean Delvare # for hwmon, i2c-core and i2c/muxes
    Acked-by: Corey Minyard # for IPMI
    Reviewed-by: Vladimir Oltean
    Acked-by: Dmitry Torokhov
    Acked-by: Sebastian Reichel # for drivers/power
    Acked-by: Krzysztof Hałasa
    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Wolfram Sang

    Uwe Kleine-König
     

29 Jun, 2022

1 commit


09 Jun, 2022

1 commit

  • Similar to the handling of play_deferred in commit 19cfe912c37b
    ("Bluetooth: btusb: Fix memory leak in play_deferred"), we thought
    a patch might be needed here as well.

    Currently usb_submit_urb is called directly to submit deferred tx
    urbs after unanchor them.

    So the usb_giveback_urb_bh would failed to unref it in usb_unanchor_urb
    and cause memory leak.

    Put those urbs in tx_anchor to avoid the leak, and also fix the error
    handling.

    Signed-off-by: Xiaohui Zhang
    Acked-by: Krzysztof Kozlowski
    Link: https://lore.kernel.org/r/20220607083230.6182-1-xiaohuizhang@ruc.edu.cn
    Signed-off-by: Jakub Kicinski

    Xiaohui Zhang
     

01 May, 2022

1 commit

  • There are destructive operations such as nfcmrvl_fw_dnld_abort and
    gpio_free in nfcmrvl_nci_unregister_dev. The resources such as firmware,
    gpio and so on could be destructed while the upper layer functions such as
    nfcmrvl_fw_dnld_start and nfcmrvl_nci_recv_frame is executing, which leads
    to double-free, use-after-free and null-ptr-deref bugs.

    There are three situations that could lead to double-free bugs.

    The first situation is shown below:

    (Thread 1) | (Thread 2)
    nfcmrvl_fw_dnld_start |
    ... | nfcmrvl_nci_unregister_dev
    release_firmware() | nfcmrvl_fw_dnld_abort
    kfree(fw) //(1) | fw_dnld_over
    | release_firmware
    ... | kfree(fw) //(2)
    | ...

    The second situation is shown below:

    (Thread 1) | (Thread 2)
    nfcmrvl_fw_dnld_start |
    ... |
    mod_timer |
    (wait a time) |
    fw_dnld_timeout | nfcmrvl_nci_unregister_dev
    fw_dnld_over | nfcmrvl_fw_dnld_abort
    release_firmware | fw_dnld_over
    kfree(fw) //(1) | release_firmware
    ... | kfree(fw) //(2)

    The third situation is shown below:

    (Thread 1) | (Thread 2)
    nfcmrvl_nci_recv_frame |
    if(..->fw_download_in_progress)|
    nfcmrvl_fw_dnld_recv_frame |
    queue_work |
    |
    fw_dnld_rx_work | nfcmrvl_nci_unregister_dev
    fw_dnld_over | nfcmrvl_fw_dnld_abort
    release_firmware | fw_dnld_over
    kfree(fw) //(1) | release_firmware
    | kfree(fw) //(2)

    The firmware struct is deallocated in position (1) and deallocated
    in position (2) again.

    The crash trace triggered by POC is like below:

    BUG: KASAN: double-free or invalid-free in fw_dnld_over
    Call Trace:
    kfree
    fw_dnld_over
    nfcmrvl_nci_unregister_dev
    nci_uart_tty_close
    tty_ldisc_kill
    tty_ldisc_hangup
    __tty_hangup.part.0
    tty_release
    ...

    What's more, there are also use-after-free and null-ptr-deref bugs
    in nfcmrvl_fw_dnld_start. If we deallocate firmware struct, gpio or
    set null to the members of priv->fw_dnld in nfcmrvl_nci_unregister_dev,
    then, we dereference firmware, gpio or the members of priv->fw_dnld in
    nfcmrvl_fw_dnld_start, the UAF or NPD bugs will happen.

    This patch reorders destructive operations after nci_unregister_device
    in order to synchronize between cleanup routine and firmware download
    routine.

    The nci_unregister_device is well synchronized. If the device is
    detaching, the firmware download routine will goto error. If firmware
    download routine is executing, nci_unregister_device will wait until
    firmware download routine is finished.

    Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support")
    Signed-off-by: Duoming Zhou
    Signed-off-by: David S. Miller

    Duoming Zhou
     

09 Feb, 2022

1 commit

  • The value returned by an spi driver's remove function is mostly ignored.
    (Only an error message is printed if the value is non-zero that the
    error is ignored.)

    So change the prototype of the remove function to return no value. This
    way driver authors are not tempted to assume that passing an error to
    the upper layer is a good idea. All drivers are adapted accordingly.
    There is no intended change of behaviour, all callbacks were prepared to
    return 0 before.

    Signed-off-by: Uwe Kleine-König
    Acked-by: Marc Kleine-Budde
    Acked-by: Andy Shevchenko
    Reviewed-by: Geert Uytterhoeven
    Acked-by: Jérôme Pouiller
    Acked-by: Miquel Raynal
    Acked-by: Jonathan Cameron
    Acked-by: Claudius Heine
    Acked-by: Stefan Schmidt
    Acked-by: Alexandre Belloni
    Acked-by: Ulf Hansson # For MMC
    Acked-by: Marcus Folkesson
    Acked-by: Łukasz Stelmach
    Acked-by: Lee Jones
    Link: https://lore.kernel.org/r/20220123175201.34839-6-u.kleine-koenig@pengutronix.de
    Signed-off-by: Mark Brown

    Uwe Kleine-König
     

13 Sep, 2021

1 commit


26 Aug, 2021

1 commit


30 Jul, 2021

1 commit


29 Jul, 2021

2 commits


25 Jul, 2021

1 commit

  • The struct nci_ops is modified by NFC core in only one case:
    nci_allocate_device() receives too many proprietary commands (prop_ops)
    to configure. This is a build time known constrain, so a graceful
    handling of such case is not necessary.

    Instead, fail the nci_allocate_device() and add BUILD_BUG_ON() to places
    which set these.

    This allows to constify the struct nci_ops (consisting of function
    pointers) for correctness and safety.

    Signed-off-by: Krzysztof Kozlowski
    Signed-off-by: David S. Miller

    Krzysztof Kozlowski
     

04 Jun, 2021

2 commits


01 Jun, 2021

3 commits


29 May, 2021

2 commits

  • The nci_ctrl_hdr.plen field us u8, so checkign if it is bigger than
    NCI_MAX_PAYLOAD_SIZE does not make any sense. Fix warning reported by
    Smatch:

    drivers/nfc/nfcmrvl/i2c.c:52 nfcmrvl_i2c_read() warn:
    impossible condition '(nci_hdr.plen > 255) => (0-255 > 255)'

    Signed-off-by: Krzysztof Kozlowski
    Link: https://lore.kernel.org/r/20210528124200.79655-6-krzysztof.kozlowski@canonical.com
    Signed-off-by: Jakub Kicinski

    Krzysztof Kozlowski
     
  • The driver can match either via OF or I2C ID tables. If OF is disabled,
    the table will be unused:

    drivers/nfc/nfcmrvl/spi.c:199:34: warning:
    ‘of_nfcmrvl_spi_match’ defined but not used [-Wunused-const-variable=]

    Signed-off-by: Krzysztof Kozlowski
    Link: https://lore.kernel.org/r/20210528124200.79655-5-krzysztof.kozlowski@canonical.com
    Signed-off-by: Jakub Kicinski

    Krzysztof Kozlowski
     

24 May, 2021

1 commit

  • The opening comment mark '/**' is used for highlighting the beginning of
    kernel-doc comments.
    The header for drivers/nfc/nfcmrvl follows this syntax, but the content
    inside does not comply with kernel-doc.

    This line was probably not meant for kernel-doc parsing, but is parsed
    due to the presence of kernel-doc like comment syntax(i.e, '/**'), which
    causes unexpected warnings from kernel-doc.
    For e.g., running scripts/kernel-doc -none on drivers/nfc/nfcmrvl/spi.c
    causes warning:
    warning: expecting prototype for Marvell NFC(). Prototype was for SPI_WAIT_HANDSHAKE() instead

    Provide a simple fix by replacing such occurrences with general comment
    format, i.e. '/*', to prevent kernel-doc from parsing it.

    Signed-off-by: Aditya Srivastava
    Acked-by: Randy Dunlap
    Signed-off-by: David S. Miller

    Aditya Srivastava
     

21 Nov, 2019

1 commit


07 Oct, 2019

1 commit


06 Aug, 2019

1 commit

  • Fix two reset-gpio sanity checks which were never converted to use
    gpio_is_valid(), and make sure to use -EINVAL to indicate a missing
    reset line also for the UART-driver module parameter and for the USB
    driver.

    This specifically prevents the UART and USB drivers from incidentally
    trying to request and use gpio 0, and also avoids triggering a WARN() in
    gpio_to_desc() during probe when no valid reset line has been specified.

    Fixes: e33a3f84f88f ("NFC: nfcmrvl: allow gpio 0 for reset signalling")
    Reported-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com
    Tested-by: syzbot+cf35b76f35e068a1107f@syzkaller.appspotmail.com
    Signed-off-by: Johan Hovold

    Johan Hovold
     

21 May, 2019

1 commit


24 Oct, 2018

1 commit

  • Use the new of_get_compatible_child() helper to lookup the nfc child
    node instead of using of_find_compatible_node(), which searches the
    entire tree from a given start node and thus can return an unrelated
    (i.e. non-child) node.

    This also addresses a potential use-after-free (e.g. after probe
    deferral) as the tree-wide helper drops a reference to its first
    argument (i.e. the parent node).

    Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver")
    Fixes: d8e018c0b321 ("NFC: nfcmrvl: update device tree bindings for Marvell NFC")
    Cc: stable # 4.2
    Cc: Vincent Cuissard
    Cc: Samuel Ortiz
    Signed-off-by: Johan Hovold
    Signed-off-by: Rob Herring

    Johan Hovold
     

28 Jun, 2018

1 commit

  • The USB completion callback does not disable interrupts while acquiring
    the lock. We want to remove the local_irq_disable() invocation from
    __usb_hcd_giveback_urb() and therefore it is required for the callback
    handler to disable the interrupts while acquiring the lock.
    The callback may be invoked either in IRQ or BH context depending on the
    USB host controller.
    Use the _irqsave() variant of the locking primitives.

    Cc: Samuel Ortiz
    Cc: linux-wireless@vger.kernel.org
    Signed-off-by: Sebastian Andrzej Siewior
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Andrzej Siewior
     

22 Nov, 2017

1 commit

  • This converts all remaining setup_timer() calls that use a nested field
    to reach a struct timer_list. Coccinelle does not have an easy way to
    match multiple fields, so a new script is needed to change the matches of
    "&_E->_timer" into "&_E->_field1._timer" in all the rules.

    spatch --very-quiet --all-includes --include-headers \
    -I ./arch/x86/include -I ./arch/x86/include/generated \
    -I ./include -I ./arch/x86/include/uapi \
    -I ./arch/x86/include/generated/uapi -I ./include/uapi \
    -I ./include/generated/uapi --include ./include/linux/kconfig.h \
    --dir . \
    --cocci-file ~/src/data/timer_setup-2fields.cocci

    @fix_address_of depends@
    expression e;
    @@

    setup_timer(
    -&(e)
    +&e
    , ...)

    // Update any raw setup_timer() usages that have a NULL callback, but
    // would otherwise match change_timer_function_usage, since the latter
    // will update all function assignments done in the face of a NULL
    // function initialization in setup_timer().
    @change_timer_function_usage_NULL@
    expression _E;
    identifier _field1;
    identifier _timer;
    type _cast_data;
    @@

    (
    -setup_timer(&_E->_field1._timer, NULL, _E);
    +timer_setup(&_E->_field1._timer, NULL, 0);
    |
    -setup_timer(&_E->_field1._timer, NULL, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, NULL, 0);
    |
    -setup_timer(&_E._field1._timer, NULL, &_E);
    +timer_setup(&_E._field1._timer, NULL, 0);
    |
    -setup_timer(&_E._field1._timer, NULL, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, NULL, 0);
    )

    @change_timer_function_usage@
    expression _E;
    identifier _field1;
    identifier _timer;
    struct timer_list _stl;
    identifier _callback;
    type _cast_func, _cast_data;
    @@

    (
    -setup_timer(&_E->_field1._timer, _callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, &_callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, _callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, &_callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)_callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)&_callback, _E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)_callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, (_cast_func)&_callback, (_cast_data)_E);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, &_callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, &_callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)_callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)_callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)&_callback, (_cast_data)_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, (_cast_func)&_callback, (_cast_data)&_E);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    _E->_field1._timer@_stl.function = _callback;
    |
    _E->_field1._timer@_stl.function = &_callback;
    |
    _E->_field1._timer@_stl.function = (_cast_func)_callback;
    |
    _E->_field1._timer@_stl.function = (_cast_func)&_callback;
    |
    _E._field1._timer@_stl.function = _callback;
    |
    _E._field1._timer@_stl.function = &_callback;
    |
    _E._field1._timer@_stl.function = (_cast_func)_callback;
    |
    _E._field1._timer@_stl.function = (_cast_func)&_callback;
    )

    // callback(unsigned long arg)
    @change_callback_handle_cast
    depends on change_timer_function_usage@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _origtype;
    identifier _origarg;
    type _handletype;
    identifier _handle;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *t
    )
    {
    (
    ... when != _origarg
    _handletype *_handle =
    -(_handletype *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle =
    -(void *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle;
    ... when != _handle
    _handle =
    -(_handletype *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    |
    ... when != _origarg
    _handletype *_handle;
    ... when != _handle
    _handle =
    -(void *)_origarg;
    +from_timer(_handle, t, _field1._timer);
    ... when != _origarg
    )
    }

    // callback(unsigned long arg) without existing variable
    @change_callback_handle_cast_no_arg
    depends on change_timer_function_usage &&
    !change_callback_handle_cast@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _origtype;
    identifier _origarg;
    type _handletype;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *t
    )
    {
    + _handletype *_origarg = from_timer(_origarg, t, _field1._timer);
    +
    ... when != _origarg
    - (_handletype *)_origarg
    + _origarg
    ... when != _origarg
    }

    // Avoid already converted callbacks.
    @match_callback_converted
    depends on change_timer_function_usage &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg@
    identifier change_timer_function_usage._callback;
    identifier t;
    @@

    void _callback(struct timer_list *t)
    { ... }

    // callback(struct something *handle)
    @change_callback_handle_arg
    depends on change_timer_function_usage &&
    !match_callback_converted &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _handletype;
    identifier _handle;
    @@

    void _callback(
    -_handletype *_handle
    +struct timer_list *t
    )
    {
    + _handletype *_handle = from_timer(_handle, t, _field1._timer);
    ...
    }

    // If change_callback_handle_arg ran on an empty function, remove
    // the added handler.
    @unchange_callback_handle_arg
    depends on change_timer_function_usage &&
    change_callback_handle_arg@
    identifier change_timer_function_usage._callback;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    type _handletype;
    identifier _handle;
    identifier t;
    @@

    void _callback(struct timer_list *t)
    {
    - _handletype *_handle = from_timer(_handle, t, _field1._timer);
    }

    // We only want to refactor the setup_timer() data argument if we've found
    // the matching callback. This undoes changes in change_timer_function_usage.
    @unchange_timer_function_usage
    depends on change_timer_function_usage &&
    !change_callback_handle_cast &&
    !change_callback_handle_cast_no_arg &&
    !change_callback_handle_arg@
    expression change_timer_function_usage._E;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type change_timer_function_usage._cast_data;
    @@

    (
    -timer_setup(&_E->_field1._timer, _callback, 0);
    +setup_timer(&_E->_field1._timer, _callback, (_cast_data)_E);
    |
    -timer_setup(&_E._field1._timer, _callback, 0);
    +setup_timer(&_E._field1._timer, _callback, (_cast_data)&_E);
    )

    // If we fixed a callback from a .function assignment, fix the
    // assignment cast now.
    @change_timer_function_assignment
    depends on change_timer_function_usage &&
    (change_callback_handle_cast ||
    change_callback_handle_cast_no_arg ||
    change_callback_handle_arg)@
    expression change_timer_function_usage._E;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type _cast_func;
    typedef TIMER_FUNC_TYPE;
    @@

    (
    _E->_field1._timer.function =
    -_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_field1._timer.function =
    -&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_field1._timer.function =
    -(_cast_func)_callback;
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E->_field1._timer.function =
    -(_cast_func)&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -&_callback;
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -(_cast_func)_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    |
    _E._field1._timer.function =
    -(_cast_func)&_callback
    +(TIMER_FUNC_TYPE)_callback
    ;
    )

    // Sometimes timer functions are called directly. Replace matched args.
    @change_timer_function_calls
    depends on change_timer_function_usage &&
    (change_callback_handle_cast ||
    change_callback_handle_cast_no_arg ||
    change_callback_handle_arg)@
    expression _E;
    identifier change_timer_function_usage._field1;
    identifier change_timer_function_usage._timer;
    identifier change_timer_function_usage._callback;
    type _cast_data;
    @@

    _callback(
    (
    -(_cast_data)_E
    +&_E->_field1._timer
    |
    -(_cast_data)&_E
    +&_E._field1._timer
    |
    -_E
    +&_E->_field1._timer
    )
    )

    // If a timer has been configured without a data argument, it can be
    // converted without regard to the callback argument, since it is unused.
    @match_timer_function_unused_data@
    expression _E;
    identifier _field1;
    identifier _timer;
    identifier _callback;
    @@

    (
    -setup_timer(&_E->_field1._timer, _callback, 0);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, _callback, 0L);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E->_field1._timer, _callback, 0UL);
    +timer_setup(&_E->_field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, 0);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, 0L);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_E._field1._timer, _callback, 0UL);
    +timer_setup(&_E._field1._timer, _callback, 0);
    |
    -setup_timer(&_field1._timer, _callback, 0);
    +timer_setup(&_field1._timer, _callback, 0);
    |
    -setup_timer(&_field1._timer, _callback, 0L);
    +timer_setup(&_field1._timer, _callback, 0);
    |
    -setup_timer(&_field1._timer, _callback, 0UL);
    +timer_setup(&_field1._timer, _callback, 0);
    |
    -setup_timer(_field1._timer, _callback, 0);
    +timer_setup(_field1._timer, _callback, 0);
    |
    -setup_timer(_field1._timer, _callback, 0L);
    +timer_setup(_field1._timer, _callback, 0);
    |
    -setup_timer(_field1._timer, _callback, 0UL);
    +timer_setup(_field1._timer, _callback, 0);
    )

    @change_callback_unused_data
    depends on match_timer_function_unused_data@
    identifier match_timer_function_unused_data._callback;
    type _origtype;
    identifier _origarg;
    @@

    void _callback(
    -_origtype _origarg
    +struct timer_list *unused
    )
    {
    ... when != _origarg
    }

    Signed-off-by: Kees Cook

    Kees Cook
     

06 Nov, 2017

1 commit

  • i2c_device_id are not supposed to change at runtime. All functions
    working with i2c_device_id provided by work with
    const i2c_device_id. So mark the non-const structs as const.

    Signed-off-by: Arvind Yadav
    Signed-off-by: Samuel Ortiz

    Arvind Yadav
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

19 Jun, 2017

5 commits

  • Allow gpio 0 to be used for reset signalling, and instead use negative
    errnos to disable the reset functionality.

    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Use the USB-interface rather than parent USB-device device, which is
    what this driver binds to, when registering the nci device.

    Note that using the right device is important when dealing with device-
    managed resources as the interface can be unbound independently of the
    parent device.

    Also note that private device pointer had already been set by
    nfcmrvl_nci_register_dev() so the redundant assignment can therefore be
    removed.

    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Make sure to release the device-node reference when done parsing the
    node.

    Fixes: e097dc624f78 ("NFC: nfcmrvl: add UART driver")
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • The nci-device was never deregistered in the event that
    fw-initialisation failed.

    Fix this by moving the firmware initialisation before device
    registration since the firmware work queue should be available before
    registering.

    Note that this depends on a recent fix that moved device-name
    initialisation back to to nci_allocate_device() as the
    firmware-workqueue name is now derived from the nfc-device name.

    Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support")
    Cc: stable # 4.4
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold
     
  • Use the nfc- rather than phy-device in firmware-management code that
    needs a valid struct device.

    This specifically fixes a NULL-pointer dereference in
    nfcmrvl_fw_dnld_init() during registration when the underlying tty is
    one end of a Unix98 pty.

    Note that the driver still uses the phy device for any debugging, which
    is fine for now.

    Fixes: 3194c6870158 ("NFC: nfcmrvl: add firmware download support")
    Cc: stable # 4.4
    Cc: Vincent Cuissard
    Signed-off-by: Johan Hovold
    Signed-off-by: Samuel Ortiz

    Johan Hovold