[PATCH] staging: vt6655: check returned value from kzalloc

2017-11-05 Thread Pierre-Yves Kerbrat
Return value from kzalloc was not checked in
device_init_td*_ring before using it.

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/vt6655/device_main.c | 43 
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index 1123b4f1e1d6..cf3259adde84 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -630,16 +630,24 @@ static void device_init_td0_ring(struct vnt_private *priv)
 i++, curr += sizeof(struct vnt_tx_desc)) {
desc = &priv->apTD0Rings[i];
desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC);
-
-   desc->td_info->buf = priv->tx0_bufs + i * PKT_BUF_SZ;
-   desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ;
-
-   desc->next = &(priv->apTD0Rings[(i+1) % 
priv->opts.tx_descs[0]]);
-   desc->next_desc = cpu_to_le32(curr + sizeof(struct 
vnt_tx_desc));
+   if (desc->td_info) {
+   desc->td_info->buf = priv->tx0_bufs +
+   i * PKT_BUF_SZ;
+   desc->td_info->buf_dma = priv->tx_bufs_dma0 +
+   i * PKT_BUF_SZ;
+
+   desc->next = &(priv->apTD0Rings[(i + 1) %
+   priv->opts.tx_descs[0]]);
+   desc->next_desc = cpu_to_le32(curr +
+   sizeof(struct vnt_tx_desc));
+   } else {
+   dev_err(&priv->pcid->dev, "Can not allocate td_info\n");
+   }
}
 
if (i > 0)
-   priv->apTD0Rings[i-1].next_desc = 
cpu_to_le32(priv->td0_pool_dma);
+   priv->apTD0Rings[i - 1].next_desc =
+   cpu_to_le32(priv->td0_pool_dma);
priv->apTailTD[0] = priv->apCurrTD[0] = &priv->apTD0Rings[0];
 }
 
@@ -655,16 +663,23 @@ static void device_init_td1_ring(struct vnt_private *priv)
 i++, curr += sizeof(struct vnt_tx_desc)) {
desc = &priv->apTD1Rings[i];
desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_ATOMIC);
-
-   desc->td_info->buf = priv->tx1_bufs + i * PKT_BUF_SZ;
-   desc->td_info->buf_dma = priv->tx_bufs_dma1 + i * PKT_BUF_SZ;
-
-   desc->next = &(priv->apTD1Rings[(i + 1) % 
priv->opts.tx_descs[1]]);
-   desc->next_desc = cpu_to_le32(curr + sizeof(struct 
vnt_tx_desc));
+   if (desc->td_info) {
+   desc->td_info->buf = priv->tx1_bufs + i * PKT_BUF_SZ;
+   desc->td_info->buf_dma = priv->tx_bufs_dma1 +
+   i * PKT_BUF_SZ;
+
+   desc->next = &(priv->apTD1Rings[(i + 1) %
+   priv->opts.tx_descs[1]]);
+   desc->next_desc = cpu_to_le32(curr +
+   sizeof(struct vnt_tx_desc));
+   } else {
+   dev_err(&priv->pcid->dev, "Can not allocate td_info\n");
+   }
}
 
if (i > 0)
-   priv->apTD1Rings[i-1].next_desc = 
cpu_to_le32(priv->td1_pool_dma);
+   priv->apTD1Rings[i - 1].next_desc =
+   cpu_to_le32(priv->td1_pool_dma);
priv->apTailTD[1] = priv->apCurrTD[1] = &priv->apTD1Rings[0];
 }
 
-- 
2.11.0

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


[PATCH 0/2] staging: rtl8188eu: fix typesign issues

2017-01-17 Thread Pierre-Yves Kerbrat
This patch fixes 2 issues detected with sparse (-Wtypesign)

Pierre-Yves Kerbrat (2):
  staging: rtl8188eu: fix type of wpa_ielen in rtw_get_cipher_info
  staging: rtl8188eu: fix type sign of len in rtw_get_bcn_info

 drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.11.0

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


[PATCH 1/2] staging: rtl8188eu: fix type of wpa_ielen in rtw_get_cipher_info

2017-01-17 Thread Pierre-Yves Kerbrat
wpa_ielen was declared u32 when we actually use an int

Fix sparse (-Wtypesign) issues:
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1008:60: warning:
incorrect type in argument 2 (different signedness)
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1008:60:expected int
*wpa_ie_len
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1008:60:got unsigned
int *
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1021:69: warning:
incorrect type in argument 2 (different signedness)

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c 
b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index 3e7a1767607e..b074de5e93f8 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -1000,7 +1000,7 @@ int ieee80211_get_hdrlen(u16 fc)
 
 static int rtw_get_cipher_info(struct wlan_network *pnetwork)
 {
-   u32 wpa_ielen;
+   int wpa_ielen;
unsigned char *pbuf;
int group_cipher = 0, pairwise_cipher = 0, is8021x = 0;
int ret = _FAIL;
-- 
2.11.0

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


[PATCH 2/2] staging: rtl8188eu: fix type sign of len in rtw_get_bcn_info

2017-01-17 Thread Pierre-Yves Kerbrat
len was declared unsigned int where we use an int

Fix sparse (-Wtypesign) issues:
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1081:88: warning:
incorrect type in argument 3 (different signedness)
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1081:88:expected int
*len
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1081:88:got unsigned
int *
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1091:86: warning:
incorrect type in argument 3 (different signedness)
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1091:86:expected int
*len
drivers/staging/rtl8188eu/core/rtw_ieee80211.c:1091:86:got unsigned
int *

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c 
b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
index b074de5e93f8..d1cd34011602 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c
@@ -1045,7 +1045,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork)
__le16 le_tmp;
u16 wpa_len = 0, rsn_len = 0;
struct HT_info_element *pht_info = NULL;
-   unsigned intlen;
+   int len;
unsigned char   *p;
 
memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2);
-- 
2.11.0

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


[PATCH 1/5] staging: rtl8188eu: os_dep: remove empty lines

2016-10-19 Thread Pierre-Yves Kerbrat
Remove unnecessary empty lines (issue found by checkpatch)

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 7cd2655f27fe..2b9ae441b88e 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -12,8 +12,6 @@
  * more details.
  *
  
**/
-
-
 #define _OSDEP_SERVICE_C_
 
 #include 
-- 
2.9.3

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


[PATCH 5/5] staging: rtl8188eu: os_dep: remove unnecessary alloc fail message

2016-10-19 Thread Pierre-Yves Kerbrat
Remove redundant alloc fail message
This patch fixes the warning found by checkpatch

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 8 +++-
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index c036fe7d1df8..6ff836f481da 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -43,14 +43,12 @@ void *rtw_malloc2d(int h, int w, int size)
int j;
 
void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
-   if (!a) {
-   pr_info("%s: alloc memory fail!\n", __func__);
-   return NULL;
-   }
+   if (!a)
+   goto out;
 
for (j = 0; j < h; j++)
a[j] = ((char *)(a + h)) + j * w * size;
-
+out:
return a;
 }
 
-- 
2.9.3

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


[PATCH 2/5] staging: rtl8188eu: os_dep: fix block comment alignment issue

2016-10-19 Thread Pierre-Yves Kerbrat
Fix coding style issue in block comment in osdep_service.c found by
checkpatch tool

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 2b9ae441b88e..534e58ecc510 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -22,9 +22,10 @@
 #include 
 
 /*
-* Translate the OS dependent @param error_code to OS independent 
RTW_STATUS_CODE
-* @return: one of RTW_STATUS_CODE
-*/
+ * Translate the OS dependent @param error_code to OS independent
+ * RTW_STATUS_CODE
+ * @return: one of RTW_STATUS_CODE
+ */
 inline int RTW_STATUS_CODE(int error_code)
 {
if (error_code >= 0)
-- 
2.9.3

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


[PATCH 3/5] staging: rtl8188eu: os_dep: fix missing spaces around operators

2016-10-19 Thread Pierre-Yves Kerbrat
Fix missing space around operators in rtw_alloc2d function in
osdep_service.c

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 534e58ecc510..df5f44000cf0 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -42,14 +42,14 @@ void *rtw_malloc2d(int h, int w, int size)
 {
int j;
 
-   void **a = kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL);
+   void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
if (!a) {
pr_info("%s: alloc memory fail!\n", __func__);
return NULL;
}
 
for (j = 0; j < h; j++)
-   a[j] = ((char *)(a+h)) + j*w*size;
+   a[j] = ((char *)(a + h)) + j * w * size;
 
return a;
 }
-- 
2.9.3

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


[PATCH 4/5] staging: rtl8188eu: os_dep: remove unnecessary parentheses

2016-10-19 Thread Pierre-Yves Kerbrat
Remove parentheses in _rtw_init_queue to fix checkpatch warning

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index df5f44000cf0..c036fe7d1df8 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -54,10 +54,10 @@ void *rtw_malloc2d(int h, int w, int size)
return a;
 }
 
-void   _rtw_init_queue(struct __queue *pqueue)
+void _rtw_init_queue(struct __queue *pqueue)
 {
-   INIT_LIST_HEAD(&(pqueue->queue));
-   spin_lock_init(&(pqueue->lock));
+   INIT_LIST_HEAD(&pqueue->queue);
+   spin_lock_init(&pqueue->lock);
 }
 
 struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv)
-- 
2.9.3

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


[PATCH 0/5] staging: rtl8188eu: os_dep: fix checkpatch issues

2016-10-19 Thread Pierre-Yves Kerbrat
Hi all,

This patchset fixes some of the checkpatch issues found in
osdep_service.c file of rtl8188eu

Pierre-Yves Kerbrat (5):
  staging: rtl8188eu: os_dep: remove empty lines
  staging: rtl8188eu: os_dep: fix block comment alignment issue
  staging: rtl8188eu: os_dep: fix missing spaces around operators
  staging: rtl8188eu: os_dep: remove unnecessary parentheses
  staging: rtl8188eu: os_dep: remove unnecessary alloc fail message

 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 27 +++-
 1 file changed, 12 insertions(+), 15 deletions(-)

-- 
2.9.3

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


[PATCH] staging: rtl8188eu: os_dep: fix checkpatch issues

2016-10-18 Thread Pierre-Yves Kerbrat
This patch fixes the following:
- fix 2 block comments
- add missing spaces around operators
- remove unnecessary kzalloc fail message
- fix line over 80 char
...

Signed-off-by: Pierre-Yves Kerbrat 
---
 drivers/staging/rtl8188eu/os_dep/osdep_service.c | 31 
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c 
b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
index 7cd2655f27fe..c4cfb5b70e9a 100644
--- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c
+++ b/drivers/staging/rtl8188eu/os_dep/osdep_service.c
@@ -12,8 +12,6 @@
  * more details.
  *
  
**/
-
-
 #define _OSDEP_SERVICE_C_
 
 #include 
@@ -24,9 +22,10 @@
 #include 
 
 /*
-* Translate the OS dependent @param error_code to OS independent 
RTW_STATUS_CODE
-* @return: one of RTW_STATUS_CODE
-*/
+ * Translate the OS dependent @param error_code to OS independent
+ * RTW_STATUS_CODE
+ * @return: one of RTW_STATUS_CODE
+ */
 inline int RTW_STATUS_CODE(int error_code)
 {
if (error_code >= 0)
@@ -42,23 +41,22 @@ u8 *_rtw_malloc(u32 sz)
 void *rtw_malloc2d(int h, int w, int size)
 {
int j;
+   void **a;
 
-   void **a = kzalloc(h*sizeof(void *) + h*w*size, GFP_KERNEL);
-   if (!a) {
-   pr_info("%s: alloc memory fail!\n", __func__);
-   return NULL;
-   }
+   a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
+   if (!a)
+   goto out;
 
for (j = 0; j < h; j++)
-   a[j] = ((char *)(a+h)) + j*w*size;
-
+   a[j] = ((char *)(a + h)) + j * w * size;
+out:
return a;
 }
 
-void   _rtw_init_queue(struct __queue *pqueue)
+void _rtw_init_queue(struct __queue *pqueue)
 {
-   INIT_LIST_HEAD(&(pqueue->queue));
-   spin_lock_init(&(pqueue->lock));
+   INIT_LIST_HEAD(&pqueue->queue);
+   spin_lock_init(&pqueue->lock);
 }
 
 struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv)
@@ -66,7 +64,8 @@ struct net_device *rtw_alloc_etherdev_with_old_priv(void 
*old_priv)
struct net_device *pnetdev;
struct rtw_netdev_priv_indicator *pnpi;
 
-   pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 
4);
+   pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator),
+   4);
if (!pnetdev)
goto RETURN;
 
-- 
2.9.3

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