Pointers to structures udphdr and dhcpMessage are derived by casting
adjacent pointers with size_t. Such typecast of pointer using size_t
is not preferred. The code looks complex and delicate. Simplify such
casting by utilizing generic "void *" casting.
Michael Straube [Sun, 6 Nov 2022 13:34:43 +0000 (14:34 +0100)]
staging: r8188eu: clean up error handling in rtw_start_drv_threads()
Convert the error handling in the function rtw_start_drv_threads() to
the common logic used in the kernel. Another step to get rid of _FAIL
and _SUCCESS which uses inverted logic.
Martin Kaiser [Sun, 6 Nov 2022 12:48:57 +0000 (13:48 +0100)]
staging: r8188eu: remove state checks in rtw_led_control
There's no need to check for bSurpriseRemoved or bDriverStopped in the
rtw_led_control function. This function schedules a delayed worker which
calls SwLedOn or SwLedOff (or the function calls SwLedOff directly).
SwLedOn and SwLedOff check bDriverStopped themselves or they initiate a
USB control transfer via usb_write, where bSurpriseRemoved is checked.
Martin Kaiser [Sun, 6 Nov 2022 12:48:53 +0000 (13:48 +0100)]
staging: r8188eu: don't store addba request
There's no need to store an incoming addba request in struct
mlme_ext_info. We only need the addba request to copy some of its fields
into our addba response.
It's simpler to pass the incoming request's management frame to
issue_action_BA as an additional parameter. issue_action_BA can then
extract the required fields. If issue_action_BA prepares a request rather
than a response, the caller sets the parameter for the incoming request to
NULL.
return boolean values. Convert their return type to bool and replace
_FAIL, which is defined as 0, with false. Another step to get rid of
_SUCCESS / _FAIL.
Some structures are only declared but have not been used anywhere
in the code. Remove such unused structs. Issue identified as part
of coccicheck report driven code investigation.
Suggested-by: Pavel Skripkin <paskripkin@gmail.com> Signed-off-by: Deepak R Varma <drv@mailo.com> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150 Link: https://lore.kernel.org/r/Y2LYvhr74ng+xFbz@qemulion Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Deepak R Varma [Sun, 6 Nov 2022 10:21:58 +0000 (15:51 +0530)]
staging: emxx_udc: use min helper macro for variable comparison
Simplify code by using min helper macros in place of lengthy if/else
block oriented logical evaluation and value assignment. This issue is
identified by coccicheck using the minmax.cocci file.
Deepak R Varma [Sat, 5 Nov 2022 11:15:52 +0000 (16:45 +0530)]
staging: rtl8723bs: replace underutilized struct by array variable
For structure iqk_matrix_regs_setting, only the "Value" member variable
is utilized whereas the other struct members are only declared but not
utilised. Replace the struct declaration and implementation by an
equivalent variable similar to the only used struct member variable.
While in there, update the macro mixed case names to uppercase style.
The resultant code is simpler and is easy to maintain.
Suggested-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Deepak R Varma <drv@mailo.com> Link: https://lore.kernel.org/r/Y2ZF6O1KU3zZ6r3C@qemulion Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Larry Finger [Fri, 4 Nov 2022 01:27:50 +0000 (20:27 -0500)]
staging: rtl8192e: Fix divide fault when calculating beacon age
When the configuration parameter CONFIG_HZ is less that 100, the compiler
generates an error as follows:
../drivers/staging/rtl8192e/rtllib_wx.c: In function 'rtl819x_translate_scan':
../drivers/staging/rtl8192e/rtllib_wx.c:220:57: warning: division by zero [-Wdiv-by-zero]
220 | (jiffies - network->last_scanned) / (HZ / 100));
| ^
In file included from ../include/linux/skbuff.h:45,
from ../include/linux/if_ether.h:19,
from ../include/linux/etherdevice.h:20,
from ../drivers/staging/rtl8192e/rtllib_wx.c:18:
../drivers/staging/rtl8192e/rtllib_wx.c: In function 'rtllib_wx_get_scan':
../drivers/staging/rtl8192e/rtllib_wx.c:261:70: warning: division by zero [-Wdiv-by-zero]
261 | (jiffies - network->last_scanned) /
|
In fact, is HZ is not a multiple of 100, the calculation will be wrong,
but it will compile correctly.
The fix is to get rid of the (HZ / 100) portion. To decrease any round-off
errors, the compiler is forced to perform the 100 * jiffies-difference
before dividing by HZ. This patch is only compile tested.
Reported-by: Randy Dunlap <rdunlap@infradead.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> Link: https://lore.kernel.org/r/20221104012750.2076-1-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Phillip Potter [Thu, 3 Nov 2022 23:06:32 +0000 (23:06 +0000)]
staging: r8188eu: change return type of rtw_set_802_11_disassociate to void
Change return type of rtw_set_802_11_disassociate to void. This function
always returns 'true' no matter what, so there is no need to return a
value, and no need to check for it in the two call sites within
rtw_wx_set_mlme. Also, as we are no longer using ret in rtw_wx_set_mlme
except as the return value, just remove it and return 0 directly.
Suggested-by: Michael Straube <straube.linux@gmail.com> Signed-off-by: Phillip Potter <phil@philpotter.co.uk> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150 Link: https://lore.kernel.org/r/20221103230632.6946-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Instance IQKMatrixRegSetting of struct ijk_matrix_regs_set is
initialised and its member variables are assigned values, but it is
not used anywhere. Remove the structure and its unused implementation.
Suggested-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Deepak R Varma <drv@mailo.com> Link: https://lore.kernel.org/r/Y2P6Jj+IcPss0wFd@qemulion Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Deepak R Varma [Thu, 3 Nov 2022 09:33:29 +0000 (15:03 +0530)]
staging: rtl8723bs: Use min/max macros for variable comparison
Simplify code by using min and max helper macros in place of lengthy
if/else block oriented logical evaluation and value assignment. This
issue is identified by coccicheck using the minmax.cocci file.
Deepak R Varma [Wed, 2 Nov 2022 22:36:59 +0000 (04:06 +0530)]
staging: rtl8192e: Use min_t/max_t macros for variable comparison
Simplify code by using min_t and max_t helper macros in place of lengthy
if/else block oriented logical evaluation and value assignment. This
issue is identified by coccicheck using the minmax.cocci file.
Use the *_t variants of min/max macros to avoid compiler warnings about
data typecast.
Also, use u32 as type for min_t macro to avoid any truncation of data
associated with enum constant HT_AGG_SIZE_32K.
Signed-off-by: Deepak R Varma <drv@mailo.com> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> Link: https://lore.kernel.org/r/Y2LxC2kziM1TznhO@qemulion Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Phillip Potter [Wed, 2 Nov 2022 00:36:13 +0000 (00:36 +0000)]
staging: r8188eu: convert rtw_setdatarate_cmd to correct error semantics
Convert rtw_setdatarate_cmd function to use proper error return codes
rather than _SUCCESS and _FAIL, and a simpler 'return 0;' style. For now,
wrap rtw_enqueue_cmd call and return -EPERM if it fails, as converting
this function makes more sense later on due to its large number of callers.
Also change rtw_wx_set_rate function to pass through the proper error
code rather than just 0 or -1.
Pointer reference to struct wlan_ie_ibss_parms is added as a member
variable to 2 structures; However, these references are never used.
Remove such unused struct references. The cleanup also renders the
struct useless; so remove it as well.
Issue identified as part of coccicheck based code analysis.
Pointer reference to struct wlan_ie_tim is added as a member
variable of a structure; However, this references is never
used. Remove such unused struct reference. The cleanup also
renders the struct useless; so remove it as well.
Issue identified as part of coccicheck based code analysis.
Pointer reference to struct wlan_ie_supp_rates is added as a member
variable to 7 different structures. However, these references are
never used. Remove such unused struct references. The cleanup also
renders the struct useless; so remove it as well.
Issue identified as part of coccicheck based code analysis.
Pointer reference to struct wlan_ie_ssid is added as a member variable
to 5 different structures. However, these references are never used.
Remove such unused struct references. The cleanup also renders the
struct useless; so remove it as well.
Issue identified as part of coccicheck based code analysis.
Michael Straube [Tue, 1 Nov 2022 19:14:58 +0000 (20:14 +0100)]
staging: r8188eu: convert rtw_free_stainfo() to void
The function rtw_free_stainfo() returns always _SUCCESS and none of
its callers uses the return value. We can safely make the function
void. Yet another tiny step towards getting rid of _FAIL / _SUCCESS.
Deepak R Varma [Mon, 31 Oct 2022 17:55:39 +0000 (23:25 +0530)]
staging: rtl8192u: remove unnecessary function implementation
This driver is a single standalone driver and does not have any loading
dependencies on another associated drivers. The build results in one
single .ko object. The current implementation of the function
ieee80211_tkip_null simply returns back to the caller without any useful
instruction executions. It does not lead to auto-loading of any other
associated modules as the initial design implementation appears to be.
Hence the call to ieee80211_tkip_null() and its implementation is
unnecessary and should be removed.
staging: octeon: cvmx_ptr_to_phys() should return physaddr_t
On 32-bit without physical address extensions (e.g. sh-allmodconfig):
drivers/staging/octeon/ethernet-mem.c: In function ‘cvm_oct_free_hw_memory’:
./arch/sh/include/asm/io.h:239:32: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
239 | #define phys_to_virt(address) ((void *)(address))
| ^
drivers/staging/octeon/ethernet-mem.c:123:18: note: in expansion of macro ‘phys_to_virt’
123 | fpa = (char *)phys_to_virt(cvmx_ptr_to_phys(fpa));
| ^~~~~~~~~~~~
Fix this by making cvmx_ptr_to_phys() return physaddr_t instead of
uint64_t.
Martin Kaiser [Mon, 31 Oct 2022 20:54:10 +0000 (21:54 +0100)]
staging: r8188eu: use ether_addr_equal for address comparison
We can use ether_addr_equal instead of memcmp in
update_recvframe_phyinfo_88e for comparing the incoming frame's
destination address with our local address.
Both struct ieee80211_hdr and struct eeprom_priv's mac_addr component are
2-byte aligned.
Suggested-by: Joe Perches <joe@perches.com> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150 Signed-off-by: Martin Kaiser <martin@kaiser.cx> Link: https://lore.kernel.org/r/20221031205412.124871-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Martin Kaiser [Sun, 30 Oct 2022 17:33:25 +0000 (18:33 +0100)]
staging: r8188eu: rtw_action_public_decache's token is a u8
Both callers of rtw_action_public_decache pass a u8 value for the token
parameter. We can change token from s32 to u8 and remove the code for
token < 0.
Martin Kaiser [Sun, 30 Oct 2022 17:33:21 +0000 (18:33 +0100)]
staging: r8188eu: replace GetAddr1Ptr call in OnAction_p2p
Define a struct ieee80211_mgmt in OnAction_p2p and use it to check the
destination address. This replaces a call to the driver-specific
GetAddr1Ptr function.
Martin Kaiser [Sun, 30 Oct 2022 17:33:16 +0000 (18:33 +0100)]
staging: r8188eu: make on_action_public static void
The on_action_public function is called only by OnAction. This function
also lives in rtw_mlme_ext.c and does not check the return value from
on_action_public.
We can make on_action_public a static void function.
The ret variable is no longer needed if we don't return a value. It can
be removed.
Reported-by: kernel test robot <lkp@intel.com> Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150 Signed-off-by: Martin Kaiser <martin@kaiser.cx> Link: https://lore.kernel.org/r/20221030173326.1588647-4-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Nam Cao [Tue, 25 Oct 2022 09:12:26 +0000 (11:12 +0200)]
staging: rtl8712: fix potential memory leak
In r8712_init_drv_sw(), whenever any function call returns error, it is
returned immediately without properly cleaning up the other successfully
executed functions. This can cause memory leak.
Instead of return immediately, free all the allocated buffers first.
Nam Cao [Tue, 25 Oct 2022 09:12:25 +0000 (11:12 +0200)]
staging: rtl8712: check for return value of _r8712_init_xmit_priv()
The return value of _r8712_init_xmit_priv() is never checked and the driver
always continue execution as if all is well. This will cause problems
if, for example, buffers cannot be allocated and the driver continue and
use those buffers.
Check for return value of _r8712_init_xmit_priv() and return error (if any)
during probing.
Nam Cao [Tue, 25 Oct 2022 09:12:24 +0000 (11:12 +0200)]
staging: rtl8712: check for alloc fail in _r8712_init_recv_priv()
The function _r8712_init_recv_priv() and also r8712_init_recv_priv()
just returns silently if they fail to allocate memory. Change their
return type to int and add necessary checks and handling if they return
-ENOMEM
This commit annotated false positive for kmemleak. The reasoning is that
the buffers are freed when the driver is unloaded. However, there is
actually potential memory leak when probe fails.
Aaron Lawrence [Wed, 26 Oct 2022 12:43:51 +0000 (19:43 +0700)]
staging: rtl8192e: rtllib_crypt_tkip: rewritten comparison to NULL
Rewritten a comparison to NULL with a negation operator in
accordance with the Linux kernel coding-style regulations. The fix
was directly recommended by the checkpatch script.
Split a multiple assignments statement to individual assignments
on different lines in accordance with the Linux kernel coding-style
regulations. Also repositioned comments on it and the statement
before for increased legibility. The multiple assignments issue
was found by the checkpatch script, with the comments legibility
issue were through direct observation.
Aaron Lawrence [Wed, 26 Oct 2022 12:41:56 +0000 (19:41 +0700)]
staging: rtl8192e: rtllib_crypt_tkip: fixes on unbalanced braces
Added braces around needed arms of statements which needs them
in accordance with the Linux kernel coding-style regulations.
The issues were found with the help of the checkpatch script.
Aaron Lawrence [Wed, 26 Oct 2022 12:41:08 +0000 (19:41 +0700)]
staging: rtl8192e: rtllib_crypt_tkip: fixed alignment matching open parentheses
Aligned multiple lines to be at the same indentation of open
parentheses before it in accordance with the Linux kernel
coding-style regulations. The issues were found by running the
checkpatch script on the file.
Aaron Lawrence [Wed, 26 Oct 2022 12:40:15 +0000 (19:40 +0700)]
staging: rtl8192e: rtllib_crypt_tkip: blank line before close brace removal
Removed multiple blank lines that are not necessary before a closing
brace. The issues were found with the checkpatch script and were
dealt with in accordance with the Linux kernel coding-style guidelines.
Removed multiple unnecessary blank lines in accordance with the
Linux kernel coding-style regulations. The issues were reported by
the checkpatch script.
This patch is intended to remove unnecessary parentheses in the
rtllib_module.c file following the Linux kernel coding-style
regulations. The modification is recommended by the checkpatch script.
Emily Peri [Fri, 28 Oct 2022 18:39:19 +0000 (11:39 -0700)]
staging: rtl8723bs: replace ternary statement with min_t macro
Ternary statements that pick the min of two values can be replaced by
the macro min_t(). This improves readability, since its quicker to
understand min_t(type, x, y) than x < y ? x : y. Issue found by
coccicheck.
Removal of multiple unnecessary blank lines in accordance with the
Linux kernel coding-style regulations. Said issues ware detected on
this file by the checkpatch script.
Aaron Lawrence [Mon, 24 Oct 2022 12:30:28 +0000 (19:30 +0700)]
Staging: rtl8192e: rtllib_tx: removed unnecessary blank line before a close brace
Removed a blank line before a closing brace as it is not necessary
as per the Linux coding-style regulations. The issue was flagged by
the checkpatch script.
Aaron Lawrence [Mon, 24 Oct 2022 12:29:14 +0000 (19:29 +0700)]
Staging: rtl8192e: rtllib_tx: fixed lines ending with an open parenthesis
Fixed several lines that end with an open parenthesis to not end
with it anymore, as per the Linux kernel coding-style regulations.
The issues were flagged by the checkpatch script.
Aaron Lawrence [Mon, 24 Oct 2022 12:27:59 +0000 (19:27 +0700)]
Staging: rtl8192e: rtllib_tx: added spaces around operators
Added multiple spaces around operators which needs it as per the
Linux kernel coding-style regulations. The issues were flagged by
the checkpatch script.
Aaron Lawrence [Mon, 24 Oct 2022 12:26:59 +0000 (19:26 +0700)]
Staging: rtl8192e: rtllib_tx: fixed alignment matching open parenthesis
Aligned multiple statements to match the open parenthesis on the
line before it as per the Linux kernel coding-style regulations.
The issues were flagged by the checkpatch script.
Multiple blank lines are condensed into a single blank line as per
the Linux kernel coding-style regulations. The issues were flagged
by the checkpatch script.
Martin Kaiser [Mon, 24 Oct 2022 08:14:12 +0000 (10:14 +0200)]
staging: r8188eu: change mlme handlers to void
The mlme handlers that are called from mgt_dispatcher return an error
code. mgt_dispatcher doesn't check this error code, we can remove it and
change the handler functions to void.
For now, make only the minimum changes to the handlers for removing the
error codes. If handlers can be simplified, that'll be done it separate
patches.