[PATCH][next] staging: wfx: check for memory allocation failures from wfx_alloc_hif

2019-12-20 Thread Colin King
From: Colin Ian King 

Currently calls to wfx_alloc_hif are not checking for a null return
when a memory allocation fails and this leads to null pointer
dereferencing issues.  Fix this by adding null pointer checks and
returning passing down -ENOMEM errors where necessary. The error
checking in the current driver is a bit sparse, so this may need
some extra attention later if required.

Fixes: f95a29d40782 ("staging: wfx: add HIF commands helpers")
Signed-off-by: Colin Ian King 
---
 drivers/staging/wfx/hif_tx.c |  6 ++
 drivers/staging/wfx/sta.c| 13 +++--
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wfx/hif_tx.c b/drivers/staging/wfx/hif_tx.c
index 8a34a52dd5b9..d8e159670eae 100644
--- a/drivers/staging/wfx/hif_tx.c
+++ b/drivers/staging/wfx/hif_tx.c
@@ -366,6 +366,9 @@ int hif_set_edca_queue_params(struct wfx_vif *wvif, u16 
queue,
struct hif_req_edca_queue_params *body = wfx_alloc_hif(sizeof(*body),
   );
 
+   if (!body)
+   return -ENOMEM;
+
WARN_ON(arg->aifs > 255);
body->aifsn = arg->aifs;
body->cw_min = cpu_to_le16(arg->cw_min);
@@ -390,6 +393,9 @@ int hif_set_pm(struct wfx_vif *wvif, bool ps, int 
dynamic_ps_timeout)
struct hif_msg *hif;
struct hif_req_set_pm_mode *body = wfx_alloc_hif(sizeof(*body), );
 
+   if (!body)
+   return -ENOMEM;
+
if (ps) {
body->pm_mode.enter_psm = 1;
// Firmware does not support more than 128ms
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 9a61478d98f8..c08d691fe870 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -316,6 +316,7 @@ int wfx_conf_tx(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
 {
struct wfx_dev *wdev = hw->priv;
struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
+   int ret = 0;
 
WARN_ON(queue >= hw->queues);
 
@@ -326,10 +327,10 @@ int wfx_conf_tx(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif,
if (wvif->vif->type == NL80211_IFTYPE_STATION) {
hif_set_uapsd_info(wvif, wvif->uapsd_mask);
if (wvif->setbssparams_done && wvif->state == WFX_STATE_STA)
-   wfx_update_pm(wvif);
+   ret = wfx_update_pm(wvif);
}
mutex_unlock(>conf_mutex);
-   return 0;
+   return ret;
 }
 
 int wfx_set_rts_threshold(struct ieee80211_hw *hw, u32 value)
@@ -1322,7 +1323,7 @@ int wfx_config(struct ieee80211_hw *hw, u32 changed)
if (changed & IEEE80211_CONF_CHANGE_PS) {
wvif = NULL;
while ((wvif = wvif_iterate(wdev, wvif)) != NULL)
-   wfx_update_pm(wvif);
+   ret = wfx_update_pm(wvif);
wvif = wdev_to_wvif(wdev, 0);
}
 
@@ -1333,7 +1334,7 @@ int wfx_config(struct ieee80211_hw *hw, u32 changed)
 
 int wfx_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
 {
-   int i;
+   int i, ret = 0;
struct wfx_dev *wdev = hw->priv;
struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
 
@@ -1417,9 +1418,9 @@ int wfx_add_interface(struct ieee80211_hw *hw, struct 
ieee80211_vif *vif)
else
hif_set_block_ack_policy(wvif, 0x00, 0x00);
// Combo force powersave mode. We can re-enable it now
-   wfx_update_pm(wvif);
+   ret = wfx_update_pm(wvif);
}
-   return 0;
+   return ret;
 }
 
 void wfx_remove_interface(struct ieee80211_hw *hw,
-- 
2.24.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 5/5] staging: vt6656: set usb_set_intfdata on driver fail.

2019-12-20 Thread Malcolm Priestley
intfdata will contain stale pointer when the device is detached after
failed initialization when referenced in vt6656_disconnect

Provide driver access to it here and NULL it.

Cc: stable 
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/device.h   | 1 +
 drivers/staging/vt6656/main_usb.c | 1 +
 drivers/staging/vt6656/wcmd.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 6074ceda78bf..50e1c8918040 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -259,6 +259,7 @@ struct vnt_private {
u8 mac_hw;
/* netdev */
struct usb_device *usb;
+   struct usb_interface *intf;
 
u64 tsf_time;
u8 rx_rate;
diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 4a5d741f94f5..9cb924c54571 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -992,6 +992,7 @@ vt6656_probe(struct usb_interface *intf, const struct 
usb_device_id *id)
priv = hw->priv;
priv->hw = hw;
priv->usb = udev;
+   priv->intf = intf;
 
vnt_set_options(priv);
 
diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c
index 3eb2f11a5de1..2c5250ca2801 100644
--- a/drivers/staging/vt6656/wcmd.c
+++ b/drivers/staging/vt6656/wcmd.c
@@ -99,6 +99,7 @@ void vnt_run_command(struct work_struct *work)
if (vnt_init(priv)) {
/* If fail all ends TODO retry */
dev_err(>usb->dev, "failed to start\n");
+   usb_set_intfdata(priv->intf, NULL);
ieee80211_free_hw(priv->hw);
return;
}
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 4/5] staging: vt6656: remove bool from vnt_radio_power_on ret

2019-12-20 Thread Malcolm Priestley
The driver uses logical only error checking a bool true would flag error.

Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index 56cd77fd9ea0..7958fc165462 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -719,7 +719,7 @@ int vnt_radio_power_off(struct vnt_private *priv)
  */
 int vnt_radio_power_on(struct vnt_private *priv)
 {
-   int ret = true;
+   int ret = 0;
 
vnt_exit_deep_sleep(priv);
 
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 3/5] staging: vt6656: limit reg output to block size

2019-12-20 Thread Malcolm Priestley
vnt_control_out appears to fail when BBREG is greater than 64 writes.

Create new function that will relay an array in no larger than
the indicated block size.

It appears that this command has always failed but was ignored by
driver until the introduction of error checking.

Cc: stable  # v5.3+
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/baseband.c |  4 ++--
 drivers/staging/vt6656/usbpipe.c  | 17 +
 drivers/staging/vt6656/usbpipe.h  |  5 +
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c 
b/drivers/staging/vt6656/baseband.c
index 8d19ae71e7cc..4e651b698617 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -449,8 +449,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
 
memcpy(array, addr, length);
 
-   ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
- MESSAGE_REQUEST_BBREG, length, array);
+   ret = vnt_control_out_blocks(priv, VNT_REG_BLOCK_SIZE,
+MESSAGE_REQUEST_BBREG, length, array);
if (ret)
goto end;
 
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 488ebd98773d..d977d4777e4f 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -76,6 +76,23 @@ int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 
reg_off, u8 data)
   reg_off, reg, sizeof(u8), );
 }
 
+int vnt_control_out_blocks(struct vnt_private *priv,
+  u16 block, u8 reg, u16 length, u8 *data)
+{
+   int ret = 0, i;
+
+   for (i = 0; i < length; i += block) {
+   u16 len = min_t(int, length - i, block);
+
+   ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE,
+ i, reg, len, data + i);
+   if (ret)
+   goto end;
+   }
+end:
+   return ret;
+}
+
 int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
   u16 index, u16 length, u8 *buffer)
 {
diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h
index 95147ec7b96a..b65d9c01a211 100644
--- a/drivers/staging/vt6656/usbpipe.h
+++ b/drivers/staging/vt6656/usbpipe.h
@@ -18,6 +18,8 @@
 
 #include "device.h"
 
+#define VNT_REG_BLOCK_SIZE 64
+
 int vnt_control_out(struct vnt_private *priv, u8 request, u16 value,
u16 index, u16 length, u8 *buffer);
 int vnt_control_in(struct vnt_private *priv, u8 request, u16 value,
@@ -26,6 +28,9 @@ int vnt_control_in(struct vnt_private *priv, u8 request, u16 
value,
 int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 ref_off, u8 data);
 int vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data);
 
+int vnt_control_out_blocks(struct vnt_private *priv,
+  u16 block, u8 reg, u16 len, u8 *data);
+
 int vnt_start_interrupt_urb(struct vnt_private *priv);
 int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb);
 int vnt_tx_context(struct vnt_private *priv,
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 2/5] staging: vt6656: correct return of vnt_init_registers.

2019-12-20 Thread Malcolm Priestley
The driver standard error returns remove bool false conditions.

Cc: stable  # v5.3+
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/main_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 4ac85ecb0921..4a5d741f94f5 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -949,7 +949,7 @@ static const struct ieee80211_ops vnt_mac_ops = {
 
 int vnt_init(struct vnt_private *priv)
 {
-   if (!(vnt_init_registers(priv)))
+   if (vnt_init_registers(priv))
return -EAGAIN;
 
SET_IEEE80211_PERM_ADDR(priv->hw, priv->permanent_net_addr);
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/5] staging: vt6656: Fix non zero logical return of, usb_control_msg

2019-12-20 Thread Malcolm Priestley
Starting with commit 59608cb1de1856
("staging: vt6656: clean function's error path in usbpipe.c")
the usb control functions have returned errors throughout driver
with only logical variable checking.

However, usb_control_msg return the amount of bytes transferred
this means that normal operation causes errors.

Correct the return function so only return zero when transfer
is successful.

Cc: stable  # v5.3+
Signed-off-by: Malcolm Priestley 
---
 drivers/staging/vt6656/usbpipe.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index d3304df6bd53..488ebd98773d 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -59,7 +59,9 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 
value,
 
kfree(usb_buffer);
 
-   if (ret >= 0 && ret < (int)length)
+   if (ret == (int)length)
+   ret = 0;
+   else
ret = -EIO;
 
 end_unlock:
@@ -103,7 +105,9 @@ int vnt_control_in(struct vnt_private *priv, u8 request, 
u16 value,
 
kfree(usb_buffer);
 
-   if (ret >= 0 && ret < (int)length)
+   if (ret == (int)length)
+   ret = 0;
+   else
ret = -EIO;
 
 end_unlock:
-- 
2.24.0
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [GIT PULL] Staging driver fixes for 5.5-rc3

2019-12-20 Thread pr-tracker-bot
The pull request you sent on Fri, 20 Dec 2019 08:08:08 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
> tags/staging-5.5-rc3

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/107aff96d36fc4bf2a9ad69bc2524e9f53bde7a6

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: use break to exit while loop

2019-12-20 Thread Michael Straube
The variable bContinual in Efuse_PgPacketRead() is only used to break
out of a while loop. Remove the variable and use break instead.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c 
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index d9b0f9e6235c..0b86ae8338d9 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -402,7 +402,6 @@ static u16 Efuse_GetCurrentSize(struct adapter *pAdapter)
 int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data)
 {
u8 ReadState = PG_STATE_HEADER;
-   int bContinual = true;
int bDataEmpty = true;
u8 efuse_data, word_cnts = 0;
u16 efuse_addr = 0;
@@ -422,7 +421,7 @@ int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, 
u8 *data)
/*   Efuse has been pre-programmed dummy 5Bytes at the end 
of Efuse by CP. */
/*  Skip dummy parts to prevent unexpected data read from Efuse. */
/*  By pass right now. 2009.02.19. */
-   while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr)) {
+   while (AVAILABLE_EFUSE_ADDR(efuse_addr)) {
/*   Header Read - */
if (ReadState & PG_STATE_HEADER) {
if (efuse_OneByteRead(pAdapter, efuse_addr, 
_data) && (efuse_data != 0xFF)) {
@@ -464,7 +463,7 @@ int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, 
u8 *data)
ReadState = PG_STATE_HEADER;
}
} else {
-   bContinual = false;
+   break;
}
} else if (ReadState & PG_STATE_DATA) {
/*   Data section Read - */
-- 
2.24.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH AUTOSEL 5.4 35/52] staging/wlan-ng: add CRC32 dependency in Kconfig

2019-12-20 Thread Sasha Levin
From: Kay Friedrich 

[ Upstream commit 2740bd3351cd5a4351f458aabaa1c9b77de3867b ]

wlan-ng uses the function crc32_le,
but CRC32 wasn't a dependency of wlan-ng

Co-developed-by: Michael Kupfer 
Signed-off-by: Michael Kupfer 
Signed-off-by: Kay Friedrich 
Link: https://lore.kernel.org/r/20191127112457.2301-1-kay.friedr...@fau.de
Signed-off-by: Greg Kroah-Hartman 
Signed-off-by: Sasha Levin 
---
 drivers/staging/wlan-ng/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/wlan-ng/Kconfig b/drivers/staging/wlan-ng/Kconfig
index ac136663fa8e5..082c16a31616e 100644
--- a/drivers/staging/wlan-ng/Kconfig
+++ b/drivers/staging/wlan-ng/Kconfig
@@ -4,6 +4,7 @@ config PRISM2_USB
depends on WLAN && USB && CFG80211
select WIRELESS_EXT
select WEXT_PRIV
+   select CRC32
help
  This is the wlan-ng prism 2.5/3 USB driver for a wide range of
  old USB wireless devices.
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel