Discussion:
Staging: rtl8188eu: Fix warning of unchecked sscanf return value.
Linux Kernel Mailing List
2014-04-01 23:53:56 UTC
Permalink
Gitweb: http://git.kernel.org/linus/;a=commit;h=f12919d5c9540ae01ca42f480ccec0fd8c70a6ad
Commit: f12919d5c9540ae01ca42f480ccec0fd8c70a6ad
Parent: 94b9c616e6dbdd49e178b9d94e097a5530064093
Author: Elena Oat <***@gmail.com>
AuthorDate: Tue Mar 18 19:16:49 2014 +0200
Committer: Greg Kroah-Hartman <***@linuxfoundation.org>
CommitDate: Tue Mar 18 12:22:21 2014 -0700

Staging: rtl8188eu: Fix warning of unchecked sscanf return value.

This patch fixes the warning "unchecked sscanf return value" in file
rtw_mp.c. Zero is returned in case sscanf fails or if less than expected
items are read and assigned successfully. I have decided to return zero,
because in previous conditional statements zero was returned in case of
failure.

While at it, I have also fixed the warning of line over 80
characters.

Signed-off-by: Elena Oat <***@gmail.com>
Signed-off-by: Greg Kroah-Hartman <***@linuxfoundation.org>
---
drivers/staging/rtl8188eu/core/rtw_mp.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mp.c b/drivers/staging/rtl8188eu/core/rtw_mp.c
index 2e02b20..705f666 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mp.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mp.c
@@ -883,7 +883,7 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data)
{
u32 i, psd_pts = 0, psd_start = 0, psd_stop = 0;
u32 psd_data = 0;
Linux Kernel Mailing List
2014-04-01 23:53:45 UTC
Permalink
Gitweb: http://git.kernel.org/linus/;a=commit;h=2a8efee2c77986c455d0b46168cacd409fd1de76
Commit: 2a8efee2c77986c455d0b46168cacd409fd1de76
Parent: e03b52b5c99657a09dbecc26bfdd89628889be34
Author: Elena Oat <***@gmail.com>
AuthorDate: Tue Mar 11 08:45:29 2014 +0200
Committer: Peter P Waskiewicz Jr <***@intel.com>
CommitDate: Thu Mar 13 16:06:31 2014 -0700

Staging: rtl8188eu: Fix warning of unchecked sscanf return value.

This patch fixes the warnings produced by checkpatch "unchecked sscanf
return value" in file ioctl_linux.c.

Signed-off-by: Elena Oat <***@gmail.com>
Signed-off-by: Peter P Waskiewicz Jr <***@intel.com>
---
drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 51 +++++++++++++++++++----
1 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 3691007..3d6af64 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -2153,6 +2153,7 @@ static int rtw_wx_read32(struct net_device *dev,
u32 data32;
u32 bytes;
u8 *ptmp;
+ int rv;

padapter = (struct adapter *)rtw_netdev_priv(dev);
p = &wrqu->data;
@@ -2168,7 +2169,11 @@ static int rtw_wx_read32(struct net_device *dev,

bytes = 0;
addr = 0;
- sscanf(ptmp, "%d,%x", &bytes, &addr);
+ rv = sscanf(ptmp, "%d,%x", &bytes, &addr);
+ if (rv != 2) {
+ kfree(ptmp);
+ return -EINVAL;
+ }

switch (bytes) {
case 1:
@@ -2198,6 +2203,7 @@ static int rtw_wx_write32(struct net_device *dev,
union iwreq_data *wrqu, char *extra)
{
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev);
+ int rv;

u32 addr;
u32 data32;
@@ -2206,7 +2212,9 @@ static int rtw_wx_write32(struct net_device *dev,
bytes = 0;
addr = 0;
data32 = 0;
- sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32);
+ rv = sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32);
+ if (rv != 3)
+ return -EINVAL;

switch (bytes) {
case 1:
@@ -5652,10 +5660,14 @@ static int rtw_pm_set(struct net_device *dev,
DBG_88E("[%s] extra = %s\n", __func__, extra);

if (!memcmp(extra, "lps =", 4)) {
- sscanf(extra+4, "%u", &mode);
+ ret = sscanf(extra+4, "%u", &mode);
+ if (ret != 1)
+ return -EINVAL;
ret = rtw_pm_set_lps(padapter, mode);
} else if (!memcmp(extra, "ips =", 4)) {
- sscanf(extra+4, "%u", &mode);
+ ret = sscanf(extra+4, "%u", &mode);
+ if (ret != 1)
+ return -EINVAL;
ret = rtw_pm_set_ips(padapter, mode);
} else {
ret = -EINVAL;
@@ -6755,8 +6767,11 @@ static int rtw_mp_bandwidth(struct net_device *dev,
{
u32 bandwidth = 0, sg = 0;
struct adapter *padapter = rtw_netdev_priv(dev);
+ int rv;

- sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg);
+ rv = sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg);
+ if (rv != 2)
+ return -EINVAL;

if (bandwidth != HT_CHANNEL_WIDTH_40)
bandwidth = HT_CHANNEL_WIDTH_20;
@@ -6776,6 +6791,7 @@ static int rtw_mp_txpower(struct net_device *dev,
u32 idx_a = 0, idx_b = 0;
char *input = kmalloc(wrqu->length, GFP_KERNEL);
struct adapter *padapter = rtw_netdev_priv(dev);
+ int rv;

if (!input)
return -ENOMEM;
@@ -6783,7 +6799,11 @@ static int rtw_mp_txpower(struct net_device *dev,
kfree(input);
return -EFAULT;
}
- sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b);
+ rv = sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b);
+ if (rv != 2) {
+ kfree(input);
+ return -EINVAL;
+ }

sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a, idx_b);
padapter->mppriv.txpoweridx = (u8)idx_a;
@@ -6877,6 +6897,7 @@ static int rtw_mp_ctx(struct net_device *dev,
u32 pkTx = 1, countPkTx = 1, cotuTx = 1, CarrSprTx = 1, scTx = 1, sgleTx = 1, stop = 1;
u32 bStartTest = 1;
u32 count = 0;
+ int rv;
struct mp_priv *pmp_priv;
struct pkt_attrib *pattrib;

@@ -6896,7 +6917,9 @@ static int rtw_mp_ctx(struct net_device *dev,
sgleTx = strncmp(extra, "background, stone", 20);
pkTx = strncmp(extra, "background, pkt", 20);
stop = strncmp(extra, "stop", 4);
- sscanf(extra, "count =%d, pkt", &count);
+ rv = sscanf(extra, "count =%d, pkt", &count);
+ if (rv != 2)
+ return -EINVAL;

_rtw_memset(extra, '\0', sizeof(*extra));

@@ -7255,6 +7278,7 @@ static int rtw_mp_phypara(struct net_device *dev,
{
char *input = kmalloc(wrqu->length, GFP_KERNEL);
u32 valxcap;
+ int rv;

if (!input)
return -ENOMEM;
@@ -7265,7 +7289,11 @@ static int rtw_mp_phypara(struct net_device *dev,

DBG_88E("%s:iwpriv in =%s\n", __func__, input);

- sscanf(input, "xcap =%d", &valxcap);
+ rv = sscanf(input, "xcap =%d", &valxcap);
+ if (rv != 1) {
+ kfree(input);
+ return -EINVAL;
+ }

kfree(input);
return 0;
@@ -7831,6 +7859,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
s32 len;
u8 *extra = NULL;
u32 extra_size = 0;
+ int rv;

s32 k;
const iw_handler *priv; /* Private ioctl */
@@ -7856,7 +7885,11 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_
ptr = input;
len = input_len;

- sscanf(ptr, "%16s", cmdname);
+ rv = sscanf(ptr, "%16s", cmdname);
+ if (rv != 1) {
+ err = -EINVAL;
+ goto exit;
+ }
cmdlen = strlen(cmdname);
DBG_88E("%s: cmd =%s\n", __func__, cmdname);

--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to ***@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...