Skip to content

Commit a733e46

Browse files
navin-patidargregkh
authored andcommitted
staging: rtl8188eu: Use kstrtoul() for string to long conversion
Signed-off-by: navin patidar <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fb46424 commit a733e46

File tree

3 files changed

+17
-27
lines changed

3 files changed

+17
-27
lines changed

drivers/staging/rtl8188eu/include/osdep_service.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,6 @@ u32 rtw_ms_to_systime(u32 ms);
211211
s32 rtw_get_passing_time_ms(u32 start);
212212
s32 rtw_get_time_interval_ms(u32 start, u32 end);
213213

214-
215-
u32 rtw_atoi(u8 *s);
216-
217214
static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer)
218215
{
219216
return del_timer_sync(ptimer);

drivers/staging/rtl8188eu/os_dep/ioctl_linux.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6590,18 +6590,23 @@ static int rtw_mp_rate(struct net_device *dev,
65906590
struct iw_request_info *info,
65916591
struct iw_point *wrqu, char *extra)
65926592
{
6593-
u32 rate = MPT_RATE_1M;
6593+
unsigned long rate = MPT_RATE_1M;
65946594
char *input = kmalloc(wrqu->length, GFP_KERNEL);
65956595
struct adapter *padapter = rtw_netdev_priv(dev);
6596+
int status;
65966597

65976598
if (!input)
65986599
return -ENOMEM;
65996600
if (copy_from_user(input, wrqu->pointer, wrqu->length)) {
66006601
kfree(input);
66016602
return -EFAULT;
66026603
}
6603-
rate = rtw_atoi(input);
6604-
sprintf(extra, "Set data rate to %d", rate);
6604+
6605+
status = kstrtoul(input, 0, &rate);
6606+
if (status)
6607+
return status;
6608+
6609+
sprintf(extra, "Set data rate to %lu", rate);
66056610
kfree(input);
66066611
if (rate <= 0x7f)
66076612
rate = wifirate2_ratetbl_inx((u8)rate);
@@ -6623,17 +6628,22 @@ static int rtw_mp_channel(struct net_device *dev,
66236628
struct iw_point *wrqu, char *extra)
66246629
{
66256630
struct adapter *padapter = rtw_netdev_priv(dev);
6626-
char *input = kmalloc(wrqu->length, GFP_KERNEL);
6627-
u32 channel = 1;
6631+
char *input = kmalloc(wrqu->length, GFP_KERNEL);
6632+
unsigned long channel = 1;
6633+
int status;
66286634

66296635
if (!input)
66306636
return -ENOMEM;
66316637
if (copy_from_user(input, wrqu->pointer, wrqu->length)) {
66326638
kfree(input);
66336639
return -EFAULT;
66346640
}
6635-
channel = rtw_atoi(input);
6636-
sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel);
6641+
6642+
status = kstrtoul(input, 0, &channel);
6643+
if (status)
6644+
return status;
6645+
6646+
sprintf(extra, "Change channel %d to channel %lu", padapter->mppriv.channel, channel);
66376647

66386648
padapter->mppriv.channel = channel;
66396649
Hal_SetChannel(padapter);

drivers/staging/rtl8188eu/os_dep/osdep_service.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,6 @@ inline int RTW_STATUS_CODE(int error_code)
3939
return _FAIL;
4040
}
4141

42-
u32 rtw_atoi(u8 *s)
43-
{
44-
int num = 0, flag = 0;
45-
int i;
46-
for (i = 0; i <= strlen(s); i++) {
47-
if (s[i] >= '0' && s[i] <= '9')
48-
num = num * 10 + s[i] - '0';
49-
else if (s[0] == '-' && i == 0)
50-
flag = 1;
51-
else
52-
break;
53-
}
54-
if (flag == 1)
55-
num = num * -1;
56-
return num;
57-
}
58-
5942
u8 *_rtw_malloc(u32 sz)
6043
{
6144
u8 *pbuf = NULL;

0 commit comments

Comments
 (0)