summaryrefslogtreecommitdiff
path: root/drivers/staging/rtlwifi
AgeCommit message (Collapse)Author
2019-03-21staging: rtlwifi: Fix potential NULL pointer dereference of kzallocAditya Pakki
phydm.internal is allocated using kzalloc which is used multiple times without a check for NULL pointer. This patch avoids such a scenario by returning 0, consistent with the failure case. Signed-off-by: Aditya Pakki <pakki001@umn.edu> Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-03-21staging: rtlwifi: rtl8822b: fix to avoid potential NULL pointer dereferenceAditya Pakki
skb allocated via dev_alloc_skb can fail and return a NULL pointer. This patch avoids such a scenario and returns, consistent with other invocations. Signed-off-by: Aditya Pakki <pakki001@umn.edu> Reviewed-by: Mukesh Ojha <mojha@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-21staging: rtlwifi: Use proper enum for return in halmac_parse_psd_data_88xxNathan Chancellor
Clang warns: drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_func_88xx.c:2472:11: warning: implicit conversion from enumeration type 'enum halmac_cmd_process_status' to different enumeration type 'enum halmac_ret_status' [-Wenum-conversion] return HALMAC_CMD_PROCESS_ERROR; ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~ 1 warning generated. Fix this by using the proper enum for allocation failures, HALMAC_RET_MALLOC_FAIL, which is used in the rest of this file. Fixes: e4b08e16b7d9 ("staging: r8822be: check kzalloc return or bail") Link: https://github.com/ClangBuiltLinux/linux/issues/375 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Reviewed-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: rtlwifi: Remove set but not used variables 'dataempty, hoffset'YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtlwifi/efuse.c: In function 'efuse_pg_packet_write': drivers/staging/rtlwifi/efuse.c:922:24: warning: variable 'dataempty' set but not used [-Wunused-but-set-variable] drivers/staging/rtlwifi/efuse.c: In function 'efuse_get_current_size': drivers/staging/rtlwifi/efuse.c:1185:5: warning: variable 'hoffset' set but not used [-Wunused-but-set-variable] They're never used and can be removed. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: rtlwifi: fix spelling mistake: "Hightest" -> "Highest"Colin Ian King
Trivial fix to spelling mistake in ODM_RT_TRACE message text, fix it. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-19staging: r8822be: check kzalloc return or bailNicholas Mc Guire
The kzalloc() in halmac_parse_psd_data_88xx() can fail and return NULL so check the psd_set->data after allocation and if allocation failed return HALMAC_CMD_PROCESS_ERROR. Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Fixes: 938a0447f094 ("staging: r8822be: Add code for halmac sub-drive") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-30staging: rtlwifi: replace ---help--- with help in KconfigCezary Kierzyk
This patch fixes the checkpatch.pl warning: WARNING: prefer 'help' over '---help---' for new help texts Signed-off-by: Cezary Kierzyk <virdipravum.n008d3v@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-30drivers: staging: rtlwifi: Start statement on a tabstopFelipe Cardoso Resende
Fix the following checkpatch.pl warning: WARNING: Statements should start on a tabstop #208: FILE: pci.h:208: + /*ASPM*/ u8 const_pci_aspm; Signed-off-by: Felipe Cardoso Resende <felipecardoso.fcr@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-01-15staging: rtlwifi: rtl8822b: fix a missing check of alloc_skbKangjie Lu
__netdev_alloc_skb() return NULl when it fails. skb_put() further uses it even when the allocation fails, leading to NULL pointer dereference. The fix inserts a check for the return value of __netdev_alloc_skb(). Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-05staging: rtlwifi: fix spelling mistake "disnabled" -> "disabled"Colin Ian King
There is a spelling mistake in an ODM_RT_TRACE message, fix it. Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27staging: rb8822be Change line not to end with '('Ricardo Silva
To comply with checkpatch. CHECK: Lines should not end with a '(' +u8 rtl_mrate_idx_to_arfr_id( Signed-off-by: Ricardo Silva <ricsilvs1@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-20staging: rtlwifi: Add new line to stay in 80 charactersCristian Sicilia
The parameter is sent to next line to stay in 80 characters Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-20staging: rtlwifi: Add spaces to match open parenthesisCristian Sicilia
Added before parameters some spaces to match open parenthesis on previous line. Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-08staging: rtlwifi: Add spaces for commentsMaya Nakamura
Add spaces before and after text in comments. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-08staging: rtlwifi: Remove empty commentMaya Nakamura
Remove a comment that does not contain any text. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-08staging: rtlwifi: Improve line endingsMaya Nakamura
Edit statements so that the line does not end with an assignment operator or a parenthesis. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-07staging: rtlwifi: SET_RATE_ID inline no arg reuseCristian Sicilia
The macro SET_RATE_ID is a definition in function and undefined at end of function. Make it as inline avoid the arg reuse for macro, the name is changed in _rtl_rate_id, following the same function pattern in the file. Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-07staging: rtlwifi: Modified the line ending with a parenthesisCristian Sicilia
This patch fixes two line ending with parenthesis, which did not conform to the linux kernel coding style. Signed-off-by: Cristian Sicilia <sicilia.cristian@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-07drivers: staging: rtl*: fix spelling mistake "Orginial" -> "Original"Colin Ian King
Trivial fix to common spelling mistakes in some rtl* drivers Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05staging: rtlwifi: Keep expressions on one lineMaya Nakamura
Edit two statements to keep expressions on one line--one from Julia's feedback. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05staging: rtlwifi: Remove unnecessary conditionsMaya Nakamura
Remove conditions with no effect. Issues found by Coccinelle's semantic patch results for cond_no_effect.cocci. Eliminate checkpatch result, a line should not end with a parenthesis. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05staging: rtlwifi: Replace 1 with true and remove comparison for boolMaya Nakamura
Replace 1 with true for bool assignments and remove a comparison of a bool with 1. Issues found by Coccinelle's semantic patch results for boolinit.cocci. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05staging: rtlwifi: Remove unused functionsMaya Nakamura
Remove the five functions that are not used from the source and header files. Issue found by Coccinelle's semantic patch results for returnvar.cocci. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05staging: rtlwifi: Remove function that only returns zeroMaya Nakamura
Because the odm_sq_process_patch_rt_cid_819x_lenovo function is only called to return zero, remove the unnecessary function and change the section that calls it. Issues found by Coccinelle's semantic patch results for returnvar.cocci and checkpatch.pl. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05staging: rtlwifi: Remove function that only returns the second argumentMaya Nakamura
Because the odm_signal_scale_mapping function is only called to return the second argument, remove the unnecessary function and change the statements that call it, including removing unneeded braces and adding a blank line. Note that removing casts (u8 to s32 and back to u8) will not lose information because the value converted should be between 0 and 100. Signed-off-by: Maya Nakamura <m.maya.nakamura@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-05Staging: rtlwifi: Remove Unneeded funition halbtc_get_wifi_rssi()Bhanusree Pola
In the function halbtc_get_wifi_rssi: 1.if and else are functionally identical as they assign same value to variable 'undec_sm_pwdb'. 2.Variable 'undec_sm_pwdb' not required to just return a single value. 3.Function not needed to just return a value and so removed the function and assigned value rtlpriv->dm.undec_sm_pwdb where the function halbtc_get_wifi_rssi() is called. Signed-off-by: Bhanusree Pola <bhanusreemahesh@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-14staging: rtlwifi: phydm: fix spelling mistake "Abnrormal" -> "Abnormal"Colin Ian King
Trivial fix to spelling mistake in message text Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-09staging: rtlwifi: Remove unnecessary parenthesesNathan Chancellor
Clang warns when multiple pairs of parentheses are used for a single conditional statement. drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c:558:33: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] } else if ((is_enable_la_mode == 1)) { ~~~~~~~~~~~~~~~~~~^~~~ drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c:558:33: note: remove extraneous parentheses around the comparison to silence this warning } else if ((is_enable_la_mode == 1)) { ~ ^ ~ drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c:558:33: note: use '=' to turn this equality comparison into an assignment } else if ((is_enable_la_mode == 1)) { ^~ = 1 warning generated. Link: https://github.com/ClangBuiltLinux/linux/issues/172 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-02staging: rtlwifi: Removed unused define and code efuse_re_pg* from wifi.hRick Veens
The following: bool efuse_re_pg_sec1flag; u8 efuse_re_pg_data[8]; are not referenced anywhere in the rtlwifi code. Signed-off-by: Rick Veens <rickveens92@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-10-02staging: rtlwifi: Return -ENOMEM instead of -1Aymen Qader
Use the ENOMEM constant instead of -1 for kzalloc failure checks in rtl_halmac.c Signed-off-by: Aymen Qader <qader.aymen@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-28staging: rtlwifi: Remove set but not used variable 'ppsc'YueHaibing
Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c: In function 'halbtc_leave_lps': drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:284:21: warning: variable 'ppsc' set but not used [-Wunused-but-set-variable] drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c: In function 'halbtc_enter_lps': drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:307:21: warning: variable 'ppsc' set but not used [-Wunused-but-set-variable] Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-25staging: rtlwifi: Use proper enumerated types for Wi-Fi only interfaceNathan Chancellor
Clang warns when one enumerated type is implicitly converted to another. drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:1264:34: warning: implicit conversion from enumeration type 'enum btc_chip_interface' to different enumeration type 'enum wifionly_chip_interface' [-Wenum-conversion] wifionly_cfg->chip_interface = BTC_INTF_PCI; ~ ^~~~~~~~~~~~ drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:1267:34: warning: implicit conversion from enumeration type 'enum btc_chip_interface' to different enumeration type 'enum wifionly_chip_interface' [-Wenum-conversion] wifionly_cfg->chip_interface = BTC_INTF_USB; ~ ^~~~~~~~~~~~ drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c:1270:34: warning: implicit conversion from enumeration type 'enum btc_chip_interface' to different enumeration type 'enum wifionly_chip_interface' [-Wenum-conversion] wifionly_cfg->chip_interface = BTC_INTF_UNKNOWN; ~ ^~~~~~~~~~~~~~~~ 3 warnings generated. Use the values from the correct enumerated type, wifionly_chip_interface. BTC_INTF_UNKNOWN = WIFIONLY_INTF_UNKNOWN = 0 BTC_INTF_PCI = WIFIONLY_INTF_PCI = 1 BTC_INTF_USB = WIFIONLY_INTF_USB = 2 Link: https://github.com/ClangBuiltLinux/linux/issues/171 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-25Staging: rtlwifi: remove unnecessary NULL checkKarthik Nishanth
The member regd of the struct rtl_priv is true in a boolean context. drivers/staging/rtlwifi/regd.c:413:27: warning: address of 'rtlpriv->regd' will always evaluate to 'true' [-Wpointer-bool-conversion] if (!wiphy || !&rtlpriv->regd) ~ ~~~~~~~~~^~~~ 1 warning generated. Link: https://github.com/ClangBuiltLinux/linux/issues/170 Signed-off-by: Karthik Nishanth <nishanthkarthik@live.com> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-10Staging: rtlwifi: efuse: Fixed a line length code styling issue.Tom Todd
Fixed a code styling issue. Signed-off-by: Tom Todd <thomas.m.a.todd@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-18Merge tag 'staging-4.19-rc1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging and IIO updates from Greg KH: "Here are the big staging/iio patches for 4.19-rc1. Lots of churn here, with tons of cleanups happening in staging drivers, a removal of an old crypto driver that no one was using (skein), and the addition of some new IIO drivers. Also added was a "gasket" driver from Google that needs loads of work and the erofs filesystem. Even with adding all of the new drivers and a new filesystem, we are only adding about 1000 lines overall to the kernel linecount, which shows just how much cleanup happened, and how big the unused crypto driver was. All of these have been in the linux-next tree for a while now with no reported issues" * tag 'staging-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (903 commits) staging:rtl8192u: Remove unused macro definitions - Style staging:rtl8192u: Add spaces around '+' operator - Style staging:rtl8192u: Remove stale comment - Style staging: rtl8188eu: remove unused mp_custom_oid.h staging: fbtft: Add spaces around / - Style staging: fbtft: Erases some repetitive usage of function name - Style staging: fbtft: Adjust some empty-line problems - Style staging: fbtft: Removes one nesting level to help readability - Style staging: fbtft: Changes gamma table to define. staging: fbtft: A bit more information on dev_err. staging: fbtft: Fixes some alignment issues - Style staging: fbtft: Puts macro arguments in parenthesis to avoid precedence issues - Style staging: rtl8188eu: remove unused array dB_Invert_Table staging: rtl8188eu: remove whitespace, add missing blank line staging: rtl8188eu: use is_multicast_ether_addr in rtw_sta_mgt.c staging: rtl8188eu: remove whitespace - style staging: rtl8188eu: cleanup block comment - style staging: rtl8188eu: use is_multicast_ether_addr in rtl8188eu_xmit.c staging: rtl8188eu: use is_multicast_ether_addr in recv_linux.c staging: rtlwifi: refactor rtl_get_tcb_desc ...
2018-08-08staging: rtlwifi: refactor rtl_get_tcb_descLuke Triantafyllidis
Refactored rtl_get_tcb_desc slightly to stay within the 80 character line limit. Signed-off-by: Luke Triantafyllidis <ltriant@cpan.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-08-05Staging: rtlwifi: base: Modified the line ending with a parenthesisSohil Ladhani
This patch fixes the "Lines should not end with a '('" warning reported by checkpatch.pl script. The line containing 'rtl_mrate_idx_to_arfr_id' function previously ended with '(', which did not conform to the linux kernel coding style. Signed-off-by: Sohil Ladhani <supertakumi86@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-20Merge ra.kernel.org:/pub/scm/linux/kernel/git/torvalds/linuxDavid S. Miller
All conflicts were trivial overlapping changes, so reasonably easy to resolve. Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-16Merge 4.18-rc5 into staging-nextGreg Kroah-Hartman
We need the staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-13staging: rtlwifi: Remove empty halmac_pcie_reg.hBjorn Helgaas
halmac_pcie_reg.h is empty, so remove it and the only include of it. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-06staging: r8822be: Fix RTL8822be can't find any wireless APPing-Ke Shih
RTL8822be can't bring up properly on ASUS X530UN, and dmesg says: [ 8.591333] r8822be: module is from the staging directory, the quality is unknown, you have been warned. [ 8.593122] r8822be 0000:02:00.0: enabling device (0000 -> 0003) [ 8.669163] r8822be: Using firmware rtlwifi/rtl8822befw.bin [ 9.289939] r8822be: rtlwifi: wireless switch is on [ 10.056426] r8822be 0000:02:00.0 wlp2s0: renamed from wlan0 ... [ 11.952534] r8822be: halmac_init_hal failed [ 11.955933] r8822be: halmac_init_hal failed [ 11.956227] r8822be: halmac_init_hal failed [ 22.007942] r8822be: halmac_init_hal failed Jian-Hong reported it works if turn off ASPM with module parameter aspm=0. In order to fix this problem kindly, this commit don't turn off aspm but enlarge ASPM L1 latency to 7. Reported-by: Jian-Hong Pan <jian-hong@endlessm.com> Tested-by: Jian-Hong Pan <jian-hong@endlessm.com> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-30Merge tag 'mac80211-next-for-davem-2018-06-29' of ↵David S. Miller
git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next Small merge conflict in net/mac80211/scan.c, I preserved the kcalloc() conversion. -DaveM Johannes Berg says: ==================== This round's updates: * finally some of the promised HE code, but it turns out to be small - but everything kept changing, so one part I did in the driver was >30 patches for what was ultimately <200 lines of code ... similar here for this code. * improved scan privacy support - can now specify scan flags for randomizing the sequence number as well as reducing the probe request element content * rfkill cleanups * a timekeeping cleanup from Arnd * various other cleanups ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2018-06-28staging: rtlwifi: Fix a possible sleep-in-atomic-context bug in ↵Jia-Ju Bai
_is_fw_read_cmd_down() The driver may sleep with holding a spinlock. The function call path (from bottom to top) in Linux-4.16.7 is: [FUNC] schedule drivers/staging/rtlwifi/halmac/rtl_halmac.c, 884: schedule in _is_fw_read_cmd_down drivers/staging/rtlwifi/halmac/rtl_halmac.c, 912: _is_fw_read_cmd_down in rtl_halmac_send_h2c drivers/staging/rtlwifi/halmac/rtl_halmac.c, 907: _raw_spin_lock_irqsave in rtl_halmac_send_h2c To fix this bug, schedule() is replaced with mdelay(1). This bug is found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-18ieee80211: bump IEEE80211_MAX_AMPDU_BUF to support HEJohannes Berg
Bump the IEEE80211_MAX_AMPDU_BUF size to 0x100 for HE support and - for now - use IEEE80211_MAX_AMPDU_BUF_HT everywhere. This is derived from my internal patch, parts of which Luca had sent upstream. Signed-off-by: Luca Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2018-06-17staging: rtlwifi: Fix "Alwyas"->"Always"Sabin Mihai Rapan
Trivial fix to spelling mistake in comment text. Signed-off-by: Sabin Mihai Rapan <sabin.rapan@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17staging: rtlwifi: Fix "writen"->"written"Sabin Mihai Rapan
Trivial fix to spelling mistake in comment text. Signed-off-by: Sabin Mihai Rapan <sabin.rapan@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-17staging: rtlwifi: Fix "Trafic"->"Traffic"Sabin Mihai Rapan
Trivial fix to spelling mistake in comment text. Signed-off-by: Sabin Mihai Rapan <sabin.rapan@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-12treewide: kzalloc() -> kcalloc()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 <keescook@chromium.org>
2018-06-01staging: rtlwifi: don't check the return value of debugfs_create_fileGreg Kroah-Hartman
We never did anything with the return value, and it does not matter if the call succeeds or not (it's just debugging code), so don't even check it. Cc: Larry Finger <Larry.Finger@lwfinger.net> Cc: Ping-Ke Shih <pkshih@realtek.com> Cc: Colin Ian King <colin.king@canonical.com> Cc: "Frank A. Cancio Bello" <frank@generalsoftwareinc.com> Cc: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-05-31staging: rtlwifi: use single_open and single_release properlyTiezhu Yang
single_open() returns -ENOMEM when malloc failed, so the caller function rtl_debugfs_open_rw() should not always return 0. In addition, when using single_open(), we should use single_release() instead of seq_release() in the file_operations structure to avoid a memory leak. Signed-off-by: Tiezhu Yang <kernelpatch@126.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>