Commit Graph

195 Commits

Author SHA1 Message Date
Daniel Micay 88a5b39b69 staging/rts5208: Fix read overflow in memcpy
Noticed by FORTIFY_SOURCE, this swaps memcpy() for strncpy() to zero-value
fill the end of the buffer instead of over-reading a string from .rodata.

Signed-off-by: Daniel Micay <danielmicay@gmail.com>
[kees: wrote commit log]
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-06 16:16:10 +02:00
Jia-Ju Bai 498c4b4e9c staging: rt5208: Fix a sleep-in-atomic bug in xd_copy_page
The driver may sleep under a spin lock, and the function call path is:
rtsx_exclusive_enter_ss (acquire the lock by spin_lock)
  rtsx_enter_ss
    rtsx_power_off_card
      xd_cleanup_work
        xd_delay_write
          xd_finish_write
            xd_copy_page
              wait_timeout
                schedule_timeout --> may sleep

To fix it, "wait_timeout" is replaced with mdelay in xd_copy_page.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-06 16:16:10 +02:00
Jia-Ju Bai ed99f0141b rts5208: Fix a sleep-in-atomic bug in rtsx_exclusive_enter_ss
The driver may sleep under a spin lock, and the function call path is:
rtsx_exclusive_enter_ss (acquire the lock by spin_lock)
  rtsx_enter_ss
    rtsx_power_off_card
      sd_cleanup_work
        sd_stop_seq_mode
          sd_switch_clock
            sd_ddr_tuning
              sd_ddr_pre_tuning_tx
                sd_change_phase
                  wait_timeout
                    schedule_timeout --> may sleep

To fix it, "wait_timeout" is replaced with mdelay in sd_change_phase.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-03 17:52:00 +09:00
Jia-Ju Bai 385cab7c71 rts5208: Fix a sleep-in-atomic bug in sd_power_off_card3v3
The driver may sleep under a spin lock, and the function call path is:
rtsx_exclusive_enter_ss (acquire the lock by spin_lock)
  rtsx_enter_ss
    rtsx_power_off_card
      sd_power_off_card3v3
        wait_timeout
          schedule_timeout --> may sleep

To fix it, "wait_timeout" is replaced with mdelay in sd_power_off_card3v3.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-03 17:52:00 +09:00
Andrea della Porta 1bb90b68ab staging: rts5208: ms.c fixed checkpatch warning - using __func__ instead of hardcoded name
staging: rts5208: ms.c Fixed checkpatch warning:
WARNING: Prefer using "%s", __func__ to embedded function names
#2597: FILE: rts5208/ms.c:2597:
+       dev_dbg(rtsx_dev(chip), "ms_build_l2p_tbl: %d\n", seg_no);

Signed-off-by: Andrea della Porta <sfaragnaus@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-04-08 17:05:59 +02:00
Arushi Singhal 4f8f316be6 staging: rts5208: Replace a bit shift by a use of BIT.
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@
constant c;
@@

-1 << c
+BIT(c)

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-23 14:25:33 +01:00
simran singhal e5619b1350 staging: rts5208: Remove unnecessary cast on void pointer
The following Coccinelle script was used to detect this:
@r@
expression x;
void* e;
type T;
identifier f;
@@
(
  *((T *)e)
|
  ((T *)x)[...]
|
  ((T*)x)->f
|
- (T*)
  e
)

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-03-09 18:50:05 +01:00
Colin Ian King de9a009b93 staging: rts5208: remove unncessary result set and check, just return SUCCESS
Minor clean up, there is no need to assign result to zero, then
check if it is less than zero. Just return SUCCESS.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-03 13:01:36 +01:00
Colin Ian King 041b67b389 staging: rts5208: remove redundant retval status check
The retval status checks in the proceeding do loop return out
of function ms_read_attritbute_info if there is an error
condition,  thus we never reach the end of the loop with
retval failed status.  Therefore, the retval status check
at end of the do loop is redundant and can be removed.

Detected with CoverityScan, CID#143000 ("Logically dead code")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-02-03 13:01:36 +01:00
Omri Arad 3331f9cbdd drivers: staging: rts5208: fix endianness handling
'cb' and 'sgb' were assigned __le values but were not marked as such,
this fixes the following sparse warnings:

drivers/staging/rts5208/rtsx_transport.c:220:34: warning: incorrect type in assignment (different base types)
drivers/staging/rts5208/rtsx_transport.c:220:34:    expected unsigned int [unsigned] [usertype] <noident>
drivers/staging/rts5208/rtsx_transport.c:220:34:    got restricted __le32 [usertype] <noident>
drivers/staging/rts5208/rtsx_transport.c:319:44: warning: incorrect type in assignment (different base types)
drivers/staging/rts5208/rtsx_transport.c:319:44:    expected unsigned long long [unsigned] [long] [long long] [usertype] <noident>
drivers/staging/rts5208/rtsx_transport.c:319:44:    got restricted __le64 [usertype] <noident>
drivers/staging/rts5208/rtsx_transport.c:319:44: warning: incorrect type in assignment (different base types)
drivers/staging/rts5208/rtsx_transport.c:319:44:    expected unsigned long long [unsigned] [long] [long long] [usertype] <noident>
drivers/staging/rts5208/rtsx_transport.c:319:44:    got restricted __le64 [usertype] <noident>

Signed-off-by: Omri Arad <omriarad3@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-01-16 18:08:57 +01:00
Wei Yongjun ef5aa934cf staging: rts5208: rtsx.c: Fix invalid use of sizeof in rtsx_probe()
sizeof() when applied to a pointer typed expression gives the
size of the pointer, not that of the pointed data.

Fixes: 2eb9d8cbb3 ("staging: rts5208: rtsx.c: Alloc sizeof struct")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-25 09:59:48 +02:00
Wayne Porter b41514b1de staging: rts5208: rtsx.c: Alignment fix
Line goes too long when aligned with parenthesis, so moved to a new line

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:20 +02:00
Wayne Porter 88936fe853 staging: rts5208: rtsx_chip.c: Long lines
Fix lines that go over 80 characters to stop warnings from checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:19 +02:00
Wayne Porter 7b468a297d staging: rts5208: rtxs_chip.h: Long lines
Move comments above long definitions so they don't go over 80 characters

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:18 +02:00
Wayne Porter 7314203b38 staging: rts5208: rtsx_scsi.h: Long lines
Aligning with parenthesis causes lines to go too long, so the
parenthesis are on a new line

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:17 +02:00
Wayne Porter d264ceb779 staging: rts5208: CamelCase fix
Change label to not use camel case per checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:16 +02:00
Wayne Porter a3e7c0928b staging: rts5208: ms.c: Braces fix
Add braces to all arms of if statement

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:14 +02:00
Wayne Porter 36e32ee542 staging: rts5208: ms.c: Multiple assignments
Fix check found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:13 +02:00
Wayne Porter 25ccf0b0a7 staging: rts5208: ms.c: Long Lines
Fix long lines detected by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:12 +02:00
Wayne Porter 9c378f1488 staging: rts5208: ms.c: Parenthesis alignment
Fix checkpatch messages: Alignment should match open parenthesis

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:11 +02:00
Wayne Porter 8473e5bb5c staging: rts5208: ms.h: Parenthesis alignment
Fix alignment to match open parenthesis

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:10 +02:00
Wayne Porter 2eb9d8cbb3 staging: rts5208: rtsx.c: Alloc sizeof struct
Satisfy checkpatch message:  Prefer kzalloc(sizeof(*dev->chip)...) over
kzalloc(sizeof(struct rtsx_chip)...)

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:09 +02:00
Wayne Porter 8149b9ab57 staging: rts5208: rtsx.c: Spacing
Remove blank line after opening {

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:08 +02:00
Wayne Porter cd4b77586b staging: rts5208: rtsx.c: CamelCase
Make camel case labels all lowercase

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:07 +02:00
Wayne Porter 7e0ea476ed staging: rts5208: rtsx.c: Spacing
Add spaces around operator for readability

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:06 +02:00
Wayne Porter cd5491af0d staging: rts5208: rtsx.c: Multiple assignments
Fix multiple assignments found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:05 +02:00
Wayne Porter c8b07957c4 staging: rts5208: rtsx.c: Alignment
Fix to match open parenthesis in order to satisfy checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:04 +02:00
Wayne Porter 379dfd3269 staging: rts5208: rtsx.c: Unnecessary parentheses
Remove parentheses found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:03 +02:00
Wayne Porter a38e369b31 staging: rts5208: Comparison to NULL
Fix to resolve checkpatch message

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:02 +02:00
Wayne Porter 911e84a09a staging: rts5208: Spacing
Adding space around operator for better readability and to stop
checkpatch check messages

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:01 +02:00
Wayne Porter 117b6038b2 staging: rts5208: Unnecessary parentheses
Remove parentheses found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:27:00 +02:00
Wayne Porter e379c79bae staging: rts5208: Parenthesis alignment
Fix alignment to stop checkpath check messages

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:59 +02:00
Wayne Porter f5becff728 staging: rts5208: Unecessary parantheses
Remove parentheses to stop checkpatch check message

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:58 +02:00
Wayne Porter 5d2de0d9b7 staging: rts5208: Parenthesis alignment
Matching open parenthesis

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:57 +02:00
Wayne Porter 2c6b3b9347 staging: rts5208: Prefer using BIT macro
Replace all instances of (1 << x) with BIT(x) to satisfy checkpatch
check messages

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:56 +02:00
Wayne Porter 15794518d7 staging: rts5208: Long lines fixes
Break up long lines in rtsx_chip.h

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:55 +02:00
Wayne Porter 33f28123af staging: rts5208: Alignment fixes
Fix alignment issues that checkpatch found

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:54 +02:00
Wayne Porter 3f19de3681 staging: rts5208: Add space around operator
Spaces are preferred around operators for readability

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:53 +02:00
Wayne Porter 44000fe6f1 staging: rts5208: Add braces to if()
Braces should be around every part of the if block and not just the else
if

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:52 +02:00
Wayne Porter f4bfffb959 staging: rts5208: Remove multiple assignment
Assign values to variables on their own lines instead of using multiple
assignment

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:51 +02:00
Wayne Porter 904af7d5b5 staging: rts5208: CamelCase fixes
Change camel case variables found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:50 +02:00
Wayne Porter 33a1b1cd2e staging: rts5208: Remove parentheses
Unnecessary parentheses found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:49 +02:00
Wayne Porter 3b8cd5aa17 staging: rts5208: Alignment fixes
Align to match open parenthesis, found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:48 +02:00
Wayne Porter 7fb7a2fc40 staging: rts5208: Fix typo in function name
Searched the entire kernel for any references to this function and it
appears safe to fix the typo

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:47 +02:00
Wayne Porter ea2030d5ae staging: rts5208: Alignment fix
Fix issue found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:46 +02:00
Wayne Porter c3cca2d1b4 staging: rts5208: Unnecessary parentheses cleanup
Remove parentheses found by checkpatch

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:45 +02:00
Wayne Porter 5426c164ff staging: rts5208: Alignment fixes
Cleaning up checkpatch issues

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:44 +02:00
Wayne Porter fe421a75ec staging: rts5208: sd.c: Spacing cleanup
Add/remove spaces to make things more readable

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:43 +02:00
Wayne Porter 3c3776441f staging: rts5208: sd.c: Fix logical continuations
Checkpatch detected && at the beginning of new lines

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:42 +02:00
Wayne Porter 57a3fcfa6b staging: rts5208: sd.c: CamelCase fixes
Convert camel case lables to all lowercase

Signed-off-by: Wayne Porter <wporter82@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-10-16 10:26:41 +02:00