Commit Graph

5 Commits

Author SHA1 Message Date
Martin McConnell 43e0521f1c usb: cdnsp: Replace snprintf() with the safer scnprintf() variant
JIRA: https://issues.redhat.com/browse/RHEL-54566

commit b385ef088c7aab20a2c0dc20d390d69a6620f0f3
Author: Lee Jones <lee@kernel.org>
Date:   Thu Nov 30 10:54:36 2023 +0000

    usb: cdnsp: Replace snprintf() with the safer scnprintf() variant

    There is a general misunderstanding amongst engineers that {v}snprintf()
    returns the length of the data *actually* encoded into the destination
    array.  However, as per the C99 standard {v}snprintf() really returns
    the length of the data that *would have been* written if there were
    enough space for it.  This misunderstanding has led to buffer-overruns
    in the past.  It's generally considered safer to use the {v}scnprintf()
    variants in their place (or even sprintf() in simple cases).  So let's
    do that.

    The uses in this file all seem to assume that data *has been* written!

    Link: https://lwn.net/Articles/69419/
    Link: https://github.com/KSPP/linux/issues/105
    Cc: Pawel Laszczak <pawell@cadence.com>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: linux-usb@vger.kernel.org
    Signed-off-by: Lee Jones <lee@kernel.org>
    Link: https://lore.kernel.org/r/20231130105459.3208986-3-lee@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Martin McConnell <mmcconne@redhat.com>
2024-08-30 12:21:46 +01:00
Martin McConnell 783b8e110a usb:cdnsp: remove TRB_FLUSH_ENDPOINT command
JIRA: https://issues.redhat.com/browse/RHEL-54566

commit 2998874736bca1031ca84b0a3235a2cd09dfa426
Author: Pawel Laszczak <pawell@cadence.com>
Date:   Thu Oct 26 09:37:37 2023 +0200

    usb:cdnsp: remove TRB_FLUSH_ENDPOINT command

    Patch removes TRB_FLUSH_ENDPOINT command from driver.
    This command is not supported by controller and
    USBSSP returns TRB Error completion code for it.

    Signed-off-by: Pawel Laszczak <pawell@cadence.com>
    Acked-by: Peter Chen <peter.chen@kernel.org>
    Link: https://lore.kernel.org/r/20231026073737.165450-1-pawell@cadence.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Martin McConnell <mmcconne@redhat.com>
2024-08-30 12:21:44 +01:00
Torez Smith c18aa03a58 usb: cdnsp: fix cdnsp_decode_trb function to properly handle ret value
Bugzilla: http://bugzilla.redhat.com/2084667
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=46653455
Tested: HP ZBook 15 G5/80D5 Laptop

commit 03db9289b5ab59437e42a111a34545a7cedb5190
Author: Pawel Laszczak <pawell@cadence.com>
Date:   Wed Jan 12 06:32:37 2022 +0100

    usb: cdnsp: fix cdnsp_decode_trb function to properly handle ret value

    Variable ret in function cdnsp_decode_trb is initialized but not
    used. To fix this compiler warning patch adds checking whether the
    data buffer has not been overflowed.

    Reported-by: kernel test robot <lkp@intel.com>
    Signed-off-by: Pawel Laszczak <pawell@cadence.com>
    Link: https://lore.kernel.org/r/20220112053237.14309-1-pawell@gli-login.cadence.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Torez Smith <torez@redhat.com>
2022-07-25 15:37:26 -04:00
Pawel Laszczak 16e3610154
usb: cdnsp: Fixes for sparse warnings
Patch fixes all sparse warnings in cdsnp driver.

It fixes the following warnings:
cdnsp-ring.c:1441: warning: incorrect type in assignment
cdnsp-ring.c:1444: warning: restricted __le32 degrades to integer
cdnsp-ring.c:2200: warning: dubious: x | !y
cdnsp-gadget.c:501: warning: incorrect type in assignment
cdnsp-gadget.c:504: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:507: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:508: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:509: warning: invalid assignment: |=
cdnsp-gadget.c:510: warning: cast from restricted __le32
cdnsp-gadget.c:558: warning: incorrect type in assignment
cdnsp-gadget.c:561: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:570: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:1571: warning: incorrect type in argument 1
cdnsp-gadget.c:1602: warning: restricted __le32 degrades to integer
cdnsp-gadget.c:1760: warning: incorrect type in assignment
cdnsp-gadget.c:1762: warning: incorrect type in assignment
cdnsp-gadget.c:1763: warning: incorrect type in assignment
cdnsp-gadget.c:1764: warning: incorrect type in assignment
cdnsp-gadget.c:1765: warning: incorrect type in assignment
cdnsp-gadget.c:1766: warning: incorrect type in assignment
cdnsp-gadget.c:1767: warning: incorrect type in assignment
cdnsp-gadget.c:458: warning: cast truncates bits from constant value
                    (ffffffff07ffffff becomes 7ffffff)
cdnsp-gadget.c:666: warning: cast truncates bits from constant value
                    (ffffffff07ffffff becomes 7ffffff)
cdnsp-mem.c:762: warning: incorrect type in assignment
cdnsp-mem.c:763: warning: incorrect type in assignment
cdnsp-mem.c:928: warning: cast from restricted __le16
cdnsp-mem.c:1187: warning: incorrect type in assignment
cdnsp-mem.c:1191: warning: incorrect type in assignment
cdnsp-ep0.c:142: warning: incorrect type in assignment
cdnsp-ep0.c:144: warning: restricted __le32 degrades to integer
cdnsp-ep0.c:147: warning: restricted __le32 degrades to integer
cdnsp-ep0.c:148: warning: restricted __le32 degrades to integer
cdnsp-ep0.c:179: warning: incorrect type in argument 1
cdnsp-ep0.c:311: warning: incorrect type in argument 1
cdnsp-ep0.c:469: warning: incorrect type in assignment
cdnsp-trace.h:611:1: warning: cast from restricted __le32

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
2020-12-29 12:36:13 +08:00
Pawel Laszczak 118b2a3237
usb: cdnsp: Add tracepoints for CDNSP driver
Patch adds the series of tracepoints that can be used for
debugging issues detected in driver.

Signed-off-by: Pawel Laszczak <pawell@cadence.com>
Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
2020-12-29 12:36:13 +08:00