[PATCH] staging/rtl8188eu: Fix a possible sleep-in-atomic bug in rtw_disassoc_cmd
The driver may sleep under a spinlock, and the function call path is: rtw_set_802_11_bssid(acquire the spinlock) rtw_disassoc_cmd kzalloc(GFP_KERNEL) --> may sleep To fix it, GFP_KERNEL is replaced with GFP_ATOMIC. This bug is found by my static analysis tool and my code review. Signed-off-by: Jia-Ju Bai--- drivers/staging/rtl8188eu/core/rtw_cmd.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 9461bce..65083a7 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -508,7 +508,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ - cmdobj = kzalloc(sizeof(*cmdobj), GFP_KERNEL); + cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC); if (!cmdobj) { res = _FAIL; kfree(param); -- 1.7.9.5 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [Outreachy kernel] [PATCH v2] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
On Sun, 8 Oct 2017, Srishti Sharma wrote: > The cast to pointer types in kfree is not needed and can be dropped. > This was done using the following semantic patch by coccinelle, > except kfree((unsigned char*) pcmd->parmbuf) which was transformed by > hand because coccinelle didn't have enough type information. > > @r@ > type T,P; > T* x; > @@ > > kfree( > -(P *) > x ) > > Signed-off-by: Srishti SharmaAcked-by: Julia Lawall > --- > Changes in v2: > -Do transformation left out by coccinelle > -Improve commit message > > drivers/staging/rtl8723bs/core/rtw_cmd.c | 60 > > 1 file changed, 30 insertions(+), 30 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c > b/drivers/staging/rtl8723bs/core/rtw_cmd.c > index 1843c44..9ac2dea 100644 > --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c > +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c > @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) > } > > /* free cmd_obj */ > - kfree((unsigned char *)pcmd); > + kfree(pcmd); > } > > > @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct > ndis_802_11_ssid *ssid, > > psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); > if (psurveyPara == NULL) { > - kfree((unsigned char *) ph2c); > + kfree(ph2c); > return _FAIL; > } > > @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 > *rateset) > > pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); > if (pbsetdataratepara == NULL) { > - kfree((u8 *) ph2c); > + kfree(ph2c); > res = _FAIL; > goto exit; > } > @@ -706,8 +706,8 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 > *rateset) > void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct > cmd_obj *pcmd) > { > /* rtw_free_cmd_obj(pcmd); */ > - kfree((unsigned char *) pcmd->parmbuf); > - kfree((unsigned char *) pcmd); > + kfree(pcmd->parmbuf); > + kfree(pcmd); > } > > u8 rtw_createbss_cmd(struct adapter *padapter) > @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct > wlan_network *pnetwork) > psecnetwork = (struct wlan_bssid_ex *)>sec_bss; > if (psecnetwork == NULL) { > if (pcmd != NULL) > - kfree((unsigned char *)pcmd); > + kfree(pcmd); > > res = _FAIL; > > @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 > deauth_timeout_ms, bool enqueu > cmdobj = rtw_zmalloc(sizeof(*cmdobj)); > if (cmdobj == NULL) { > res = _FAIL; > - kfree((u8 *)param); > + kfree(param); > goto exit; > } > init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); > @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 > deauth_timeout_ms, bool enqueu > /* no need to enqueue, do the cmd hdl directly and free cmd > parameter */ > if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) > res = _FAIL; > - kfree((u8 *)param); > + kfree(param); > } > > exit: > @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum > NDIS_802_11_NETWORK_INFRAST > if (enqueue) { > ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); > if (ph2c == NULL) { > - kfree((u8 *)psetop); > + kfree(psetop); > res = _FAIL; > goto exit; > } > @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum > NDIS_802_11_NETWORK_INFRAST > res = rtw_enqueue_cmd(pcmdpriv, ph2c); > } else{ > setopmode_hdl(padapter, (u8 *)psetop); > - kfree((u8 *)psetop); > + kfree(psetop); > } > exit: > return res; > @@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct > sta_info *sta, u8 unicast_ > if (enqueue) { > ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); > if (ph2c == NULL) { > - kfree((u8 *) psetstakey_para); > + kfree(psetstakey_para); > res = _FAIL; > goto exit; > } > > psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); > if (psetstakey_rsp == NULL) { > - kfree((u8 *) ph2c); > - kfree((u8 *) psetstakey_para); > + kfree(ph2c); > + kfree(psetstakey_para); > res = _FAIL; > goto exit; > } > @@ -1061,7 +1061,7 @@ u8
[PATCH v2] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
The cast to pointer types in kfree is not needed and can be dropped. This was done using the following semantic patch by coccinelle, except kfree((unsigned char*) pcmd->parmbuf) which was transformed by hand because coccinelle didn't have enough type information. @r@ type T,P; T* x; @@ kfree( -(P *) x ) Signed-off-by: Srishti Sharma--- Changes in v2: -Do transformation left out by coccinelle -Improve commit message drivers/staging/rtl8723bs/core/rtw_cmd.c | 60 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 1843c44..9ac2dea 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) } /* free cmd_obj */ - kfree((unsigned char *)pcmd); + kfree(pcmd); } @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); if (psurveyPara == NULL) { - kfree((unsigned char *) ph2c); + kfree(ph2c); return _FAIL; } @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); if (pbsetdataratepara == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); res = _FAIL; goto exit; } @@ -706,8 +706,8 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) { /* rtw_free_cmd_obj(pcmd); */ - kfree((unsigned char *) pcmd->parmbuf); - kfree((unsigned char *) pcmd); + kfree(pcmd->parmbuf); + kfree(pcmd); } u8 rtw_createbss_cmd(struct adapter *padapter) @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecnetwork = (struct wlan_bssid_ex *)>sec_bss; if (psecnetwork == NULL) { if (pcmd != NULL) - kfree((unsigned char *)pcmd); + kfree(pcmd); res = _FAIL; @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu cmdobj = rtw_zmalloc(sizeof(*cmdobj)); if (cmdobj == NULL) { res = _FAIL; - kfree((u8 *)param); + kfree(param); goto exit; } init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) res = _FAIL; - kfree((u8 *)param); + kfree(param); } exit: @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST if (enqueue) { ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { - kfree((u8 *)psetop); + kfree(psetop); res = _FAIL; goto exit; } @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST res = rtw_enqueue_cmd(pcmdpriv, ph2c); } else{ setopmode_hdl(padapter, (u8 *)psetop); - kfree((u8 *)psetop); + kfree(psetop); } exit: return res; @@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ if (enqueue) { ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { - kfree((u8 *) psetstakey_para); + kfree(psetstakey_para); res = _FAIL; goto exit; } psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); if (psetstakey_rsp == NULL) { - kfree((u8 *) ph2c); - kfree((u8 *) psetstakey_para); + kfree(ph2c); + kfree(psetstakey_para); res = _FAIL; goto exit; } @@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ res = rtw_enqueue_cmd(pcmdpriv, ph2c); } else{ set_stakey_hdl(padapter, (u8 *)psetstakey_para); -
Re: [Outreachy kernel] [PATCH v2] Staging: pi433: Fix the position of brace after if
On Sun, 8 Oct 2017, Srishti Sharma wrote: > Fix the position of the brace after if when it is on the next line. > Done using the following semantic patch by coccinelle. > > @r1@ > position p1, p2; > @@ > > if(...)@p1 {@p2 > ... > } > > @script: python r2@ > p1 << r1.p1; > p2 << r1.p2; > @@ > > l1 = int (p1[0].line) > l2 = int (p2[0].line) > c1 = int (p1[0].column_end) > c2 = int (p2[0].column) > > if l1 == l2 and c1+1 == c2: > cocci.include_match(False) > > @r3@ > position r1.p1, r1.p2; > @@ > > if(... > - )@p1 > -{@p2 > +) { > ... > } > > Signed-off-by: Srishti SharmaAcked-by: Julia Lawall > --- > Changes in v2: > -Improve commit message. > > drivers/staging/pi433/pi433_if.c | 54 > ++-- > 1 file changed, 18 insertions(+), 36 deletions(-) > > diff --git a/drivers/staging/pi433/pi433_if.c > b/drivers/staging/pi433/pi433_if.c > index d82c74d..d946838 100644 > --- a/drivers/staging/pi433/pi433_if.c > +++ b/drivers/staging/pi433/pi433_if.c > @@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct > pi433_tx_cfg *tx_cfg) > SET_CHECKED(rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc)); > > /* configure sync, if enabled */ > - if (tx_cfg->enable_sync == optionOn) > - { > + if (tx_cfg->enable_sync == optionOn) { > SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length)); > SET_CHECKED(rf69_set_sync_values(dev->spi, > tx_cfg->sync_pattern)); > } > @@ -408,8 +407,7 @@ pi433_receive(void *data) > if (retval) goto abort; /* wait was interrupted */ > > rf69_read_fifo(spi, (u8 *)_total, 1); > - if (bytes_total > dev->rx_buffer_size) > - { > + if (bytes_total > dev->rx_buffer_size) { > retval = -1; > goto abort; > } > @@ -509,16 +507,14 @@ pi433_tx_thread(void *data) > mutex_lock(>tx_fifo_lock); > > retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg)); > - if (retval != sizeof(tx_cfg)) > - { > + if (retval != sizeof(tx_cfg)) { > dev_dbg(device->dev, "reading tx_cfg from fifo failed: > got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) ); > mutex_unlock(>tx_fifo_lock); > continue; > } > > retval = kfifo_out(>tx_fifo, , sizeof(size_t)); > - if (retval != sizeof(size_t)) > - { > + if (retval != sizeof(size_t)) { > dev_dbg(device->dev, "reading msg size from fifo > failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) ); > mutex_unlock(>tx_fifo_lock); > continue; > @@ -650,8 +646,7 @@ pi433_tx_thread(void *data) > SET_CHECKED(rf69_set_mode(spi, standby)); > > /* everything sent? */ > - if ( kfifo_is_empty(>tx_fifo) ) > - { > + if (kfifo_is_empty(>tx_fifo)) { > abort: > if (rx_interrupted) > { > @@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t > size, loff_t *f_pos) > mutex_unlock(>rx_lock); > > /* if read was successful copy to user space*/ > - if (bytes_received > 0) > - { > + if (bytes_received > 0) { > retval = copy_to_user(buf, device->rx_buffer, bytes_received); > if (retval) > return -EFAULT; > @@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned > long arg) > switch (cmd) { > case PI433_IOC_RD_TX_CFG: > tmp = _IOC_SIZE(cmd); > - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) > - { > + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { > retval = -EINVAL; > break; > } > @@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned > long arg) > break; > case PI433_IOC_WR_TX_CFG: > tmp = _IOC_SIZE(cmd); > - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) > - { > + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { > retval = -EINVAL; > break; > } > @@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file > *filp) > > if (!device->rx_buffer) { > device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); > - if (!device->rx_buffer) > - { > + if (!device->rx_buffer) { > dev_dbg(device->dev, "open/ENOMEM\n"); > return -ENOMEM; > } > @@ -926,8 +917,7 @@ static int
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
On Sun, Oct 8, 2017 at 1:36 AM, Julia Lawallwrote: > > > On Sun, 8 Oct 2017, Srishti Sharma wrote: > >> On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawall wrote: >> > >> > >> > On Sat, 7 Oct 2017, Srishti Sharma wrote: >> > >> >> The cast to pointer types in kfree is not needed and can be dropped. >> >> Done using the following semantic by coccinelle. >> >> >> >> @r@ >> >> type T,P; >> >> T* x; >> >> @@ >> >> >> >> kfree( >> >> -(P *) >> >> x ) >> >> >> >> Signed-off-by: Srishti Sharma >> >> --- >> >> drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 >> >> >> >> 1 file changed, 29 insertions(+), 29 deletions(-) >> >> >> >> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c >> >> b/drivers/staging/rtl8723bs/core/rtw_cmd.c >> >> index 1843c44..e71e3ab 100644 >> >> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c >> >> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c >> >> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) >> >> } >> >> >> >> /* free cmd_obj */ >> >> - kfree((unsigned char *)pcmd); >> >> + kfree(pcmd); >> >> } >> >> >> >> >> >> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, >> >> struct ndis_802_11_ssid *ssid, >> >> >> >> psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); >> >> if (psurveyPara == NULL) { >> >> - kfree((unsigned char *) ph2c); >> >> + kfree(ph2c); >> >> return _FAIL; >> >> } >> >> >> >> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 >> >> *rateset) >> >> >> >> pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); >> >> if (pbsetdataratepara == NULL) { >> >> - kfree((u8 *) ph2c); >> >> + kfree(ph2c); >> >> res = _FAIL; >> >> goto exit; >> >> } >> >> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter >> >> *padapter, struct cmd_obj *p >> >> { >> >> /* rtw_free_cmd_obj(pcmd); */ >> >> kfree((unsigned char *) pcmd->parmbuf); >> > >> > This case didn't get updated, probably because Coccinelle didn't have >> > access to enough type information. Try rerunning with --all-includes or >> > --recursive-includes. You may also need to give some include path >> > information (-I argument). >> I tried doing this but it is still not detecting this particular case, >> for the include path I gave the path of the directory which contains >> the header file in which struct cmd_obj is defined. > > OK, just check the field type manually, and then put a note in your commit > log saying that you have done that case by hand, due to Coccinelle's not > having sufficient type information. Yes, I have checked it , it is a pointer. Thanks, Srishti > > julia > >> >> Regards, >> Srishti >> > >> > julia >> > >> >> - kfree((unsigned char *) pcmd); >> >> + kfree(pcmd); >> >> } >> >> >> >> u8 rtw_createbss_cmd(struct adapter *padapter) >> >> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct >> >> wlan_network *pnetwork) >> >> psecnetwork = (struct wlan_bssid_ex *)>sec_bss; >> >> if (psecnetwork == NULL) { >> >> if (pcmd != NULL) >> >> - kfree((unsigned char *)pcmd); >> >> + kfree(pcmd); >> >> >> >> res = _FAIL; >> >> >> >> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 >> >> deauth_timeout_ms, bool enqueu >> >> cmdobj = rtw_zmalloc(sizeof(*cmdobj)); >> >> if (cmdobj == NULL) { >> >> res = _FAIL; >> >> - kfree((u8 *)param); >> >> + kfree(param); >> >> goto exit; >> >> } >> >> init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); >> >> @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 >> >> deauth_timeout_ms, bool enqueu >> >> /* no need to enqueue, do the cmd hdl directly and free cmd >> >> parameter */ >> >> if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) >> >> res = _FAIL; >> >> - kfree((u8 *)param); >> >> + kfree(param); >> >> } >> >> >> >> exit: >> >> @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum >> >> NDIS_802_11_NETWORK_INFRAST >> >> if (enqueue) { >> >> ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); >> >> if (ph2c == NULL) { >> >> - kfree((u8 *)psetop); >> >> + kfree(psetop); >> >> res = _FAIL; >> >> goto exit; >> >> } >> >> @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum >> >> NDIS_802_11_NETWORK_INFRAST >> >> res = rtw_enqueue_cmd(pcmdpriv, ph2c); >> >> }
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
On Sun, 8 Oct 2017, Srishti Sharma wrote: > On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawallwrote: > > > > > > On Sat, 7 Oct 2017, Srishti Sharma wrote: > > > >> The cast to pointer types in kfree is not needed and can be dropped. > >> Done using the following semantic by coccinelle. > >> > >> @r@ > >> type T,P; > >> T* x; > >> @@ > >> > >> kfree( > >> -(P *) > >> x ) > >> > >> Signed-off-by: Srishti Sharma > >> --- > >> drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 > >> > >> 1 file changed, 29 insertions(+), 29 deletions(-) > >> > >> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c > >> b/drivers/staging/rtl8723bs/core/rtw_cmd.c > >> index 1843c44..e71e3ab 100644 > >> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c > >> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c > >> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) > >> } > >> > >> /* free cmd_obj */ > >> - kfree((unsigned char *)pcmd); > >> + kfree(pcmd); > >> } > >> > >> > >> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, > >> struct ndis_802_11_ssid *ssid, > >> > >> psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); > >> if (psurveyPara == NULL) { > >> - kfree((unsigned char *) ph2c); > >> + kfree(ph2c); > >> return _FAIL; > >> } > >> > >> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 > >> *rateset) > >> > >> pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); > >> if (pbsetdataratepara == NULL) { > >> - kfree((u8 *) ph2c); > >> + kfree(ph2c); > >> res = _FAIL; > >> goto exit; > >> } > >> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter > >> *padapter, struct cmd_obj *p > >> { > >> /* rtw_free_cmd_obj(pcmd); */ > >> kfree((unsigned char *) pcmd->parmbuf); > > > > This case didn't get updated, probably because Coccinelle didn't have > > access to enough type information. Try rerunning with --all-includes or > > --recursive-includes. You may also need to give some include path > > information (-I argument). > I tried doing this but it is still not detecting this particular case, > for the include path I gave the path of the directory which contains > the header file in which struct cmd_obj is defined. OK, just check the field type manually, and then put a note in your commit log saying that you have done that case by hand, due to Coccinelle's not having sufficient type information. julia > > Regards, > Srishti > > > > julia > > > >> - kfree((unsigned char *) pcmd); > >> + kfree(pcmd); > >> } > >> > >> u8 rtw_createbss_cmd(struct adapter *padapter) > >> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct > >> wlan_network *pnetwork) > >> psecnetwork = (struct wlan_bssid_ex *)>sec_bss; > >> if (psecnetwork == NULL) { > >> if (pcmd != NULL) > >> - kfree((unsigned char *)pcmd); > >> + kfree(pcmd); > >> > >> res = _FAIL; > >> > >> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 > >> deauth_timeout_ms, bool enqueu > >> cmdobj = rtw_zmalloc(sizeof(*cmdobj)); > >> if (cmdobj == NULL) { > >> res = _FAIL; > >> - kfree((u8 *)param); > >> + kfree(param); > >> goto exit; > >> } > >> init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); > >> @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 > >> deauth_timeout_ms, bool enqueu > >> /* no need to enqueue, do the cmd hdl directly and free cmd > >> parameter */ > >> if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) > >> res = _FAIL; > >> - kfree((u8 *)param); > >> + kfree(param); > >> } > >> > >> exit: > >> @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum > >> NDIS_802_11_NETWORK_INFRAST > >> if (enqueue) { > >> ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); > >> if (ph2c == NULL) { > >> - kfree((u8 *)psetop); > >> + kfree(psetop); > >> res = _FAIL; > >> goto exit; > >> } > >> @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum > >> NDIS_802_11_NETWORK_INFRAST > >> res = rtw_enqueue_cmd(pcmdpriv, ph2c); > >> } else{ > >> setopmode_hdl(padapter, (u8 *)psetop); > >> - kfree((u8 *)psetop); > >> + kfree(psetop); > >> } > >> exit: > >> return res; > >> @@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, > >> struct
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
On Sat, Oct 7, 2017 at 11:42 PM, Julia Lawallwrote: > > > On Sat, 7 Oct 2017, Srishti Sharma wrote: > >> The cast to pointer types in kfree is not needed and can be dropped. >> Done using the following semantic by coccinelle. >> >> @r@ >> type T,P; >> T* x; >> @@ >> >> kfree( >> -(P *) >> x ) >> >> Signed-off-by: Srishti Sharma >> --- >> drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 >> >> 1 file changed, 29 insertions(+), 29 deletions(-) >> >> diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c >> b/drivers/staging/rtl8723bs/core/rtw_cmd.c >> index 1843c44..e71e3ab 100644 >> --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c >> +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c >> @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) >> } >> >> /* free cmd_obj */ >> - kfree((unsigned char *)pcmd); >> + kfree(pcmd); >> } >> >> >> @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct >> ndis_802_11_ssid *ssid, >> >> psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); >> if (psurveyPara == NULL) { >> - kfree((unsigned char *) ph2c); >> + kfree(ph2c); >> return _FAIL; >> } >> >> @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 >> *rateset) >> >> pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); >> if (pbsetdataratepara == NULL) { >> - kfree((u8 *) ph2c); >> + kfree(ph2c); >> res = _FAIL; >> goto exit; >> } >> @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter >> *padapter, struct cmd_obj *p >> { >> /* rtw_free_cmd_obj(pcmd); */ >> kfree((unsigned char *) pcmd->parmbuf); > > This case didn't get updated, probably because Coccinelle didn't have > access to enough type information. Try rerunning with --all-includes or > --recursive-includes. You may also need to give some include path > information (-I argument). I tried doing this but it is still not detecting this particular case, for the include path I gave the path of the directory which contains the header file in which struct cmd_obj is defined. Regards, Srishti > > julia > >> - kfree((unsigned char *) pcmd); >> + kfree(pcmd); >> } >> >> u8 rtw_createbss_cmd(struct adapter *padapter) >> @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct >> wlan_network *pnetwork) >> psecnetwork = (struct wlan_bssid_ex *)>sec_bss; >> if (psecnetwork == NULL) { >> if (pcmd != NULL) >> - kfree((unsigned char *)pcmd); >> + kfree(pcmd); >> >> res = _FAIL; >> >> @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 >> deauth_timeout_ms, bool enqueu >> cmdobj = rtw_zmalloc(sizeof(*cmdobj)); >> if (cmdobj == NULL) { >> res = _FAIL; >> - kfree((u8 *)param); >> + kfree(param); >> goto exit; >> } >> init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); >> @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 >> deauth_timeout_ms, bool enqueu >> /* no need to enqueue, do the cmd hdl directly and free cmd >> parameter */ >> if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) >> res = _FAIL; >> - kfree((u8 *)param); >> + kfree(param); >> } >> >> exit: >> @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum >> NDIS_802_11_NETWORK_INFRAST >> if (enqueue) { >> ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); >> if (ph2c == NULL) { >> - kfree((u8 *)psetop); >> + kfree(psetop); >> res = _FAIL; >> goto exit; >> } >> @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum >> NDIS_802_11_NETWORK_INFRAST >> res = rtw_enqueue_cmd(pcmdpriv, ph2c); >> } else{ >> setopmode_hdl(padapter, (u8 *)psetop); >> - kfree((u8 *)psetop); >> + kfree(psetop); >> } >> exit: >> return res; >> @@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, >> struct sta_info *sta, u8 unicast_ >> if (enqueue) { >> ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); >> if (ph2c == NULL) { >> - kfree((u8 *) psetstakey_para); >> + kfree(psetstakey_para); >> res = _FAIL; >> goto exit; >> } >> >> psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); >> if (psetstakey_rsp == NULL) { >> -
[PATCH v2] Staging: pi433: Fix the position of brace after if
Fix the position of the brace after if when it is on the next line. Done using the following semantic patch by coccinelle. @r1@ position p1, p2; @@ if(...)@p1 {@p2 ... } @script: python r2@ p1 << r1.p1; p2 << r1.p2; @@ l1 = int (p1[0].line) l2 = int (p2[0].line) c1 = int (p1[0].column_end) c2 = int (p2[0].column) if l1 == l2 and c1+1 == c2: cocci.include_match(False) @r3@ position r1.p1, r1.p2; @@ if(... - )@p1 -{@p2 +) { ... } Signed-off-by: Srishti Sharma--- Changes in v2: -Improve commit message. drivers/staging/pi433/pi433_if.c | 54 ++-- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index d82c74d..d946838 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) SET_CHECKED(rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc)); /* configure sync, if enabled */ - if (tx_cfg->enable_sync == optionOn) - { + if (tx_cfg->enable_sync == optionOn) { SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length)); SET_CHECKED(rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern)); } @@ -408,8 +407,7 @@ pi433_receive(void *data) if (retval) goto abort; /* wait was interrupted */ rf69_read_fifo(spi, (u8 *)_total, 1); - if (bytes_total > dev->rx_buffer_size) - { + if (bytes_total > dev->rx_buffer_size) { retval = -1; goto abort; } @@ -509,16 +507,14 @@ pi433_tx_thread(void *data) mutex_lock(>tx_fifo_lock); retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg)); - if (retval != sizeof(tx_cfg)) - { + if (retval != sizeof(tx_cfg)) { dev_dbg(device->dev, "reading tx_cfg from fifo failed: got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) ); mutex_unlock(>tx_fifo_lock); continue; } retval = kfifo_out(>tx_fifo, , sizeof(size_t)); - if (retval != sizeof(size_t)) - { + if (retval != sizeof(size_t)) { dev_dbg(device->dev, "reading msg size from fifo failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) ); mutex_unlock(>tx_fifo_lock); continue; @@ -650,8 +646,7 @@ pi433_tx_thread(void *data) SET_CHECKED(rf69_set_mode(spi, standby)); /* everything sent? */ - if ( kfifo_is_empty(>tx_fifo) ) - { + if (kfifo_is_empty(>tx_fifo)) { abort: if (rx_interrupted) { @@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) mutex_unlock(>rx_lock); /* if read was successful copy to user space*/ - if (bytes_received > 0) - { + if (bytes_received > 0) { retval = copy_to_user(buf, device->rx_buffer, bytes_received); if (retval) return -EFAULT; @@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) switch (cmd) { case PI433_IOC_RD_TX_CFG: tmp = _IOC_SIZE(cmd); - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) - { + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { retval = -EINVAL; break; } @@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) break; case PI433_IOC_WR_TX_CFG: tmp = _IOC_SIZE(cmd); - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) - { + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { retval = -EINVAL; break; } @@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file *filp) if (!device->rx_buffer) { device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); - if (!device->rx_buffer) - { + if (!device->rx_buffer) { dev_dbg(device->dev, "open/ENOMEM\n"); return -ENOMEM; } @@ -926,8 +917,7 @@ static int pi433_open(struct inode *inode, struct file *filp) device->users++; instance = kzalloc(sizeof(*instance), GFP_KERNEL); - if (!instance) - { + if (!instance) {
Re: [Outreachy kernel] [PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
On Sat, 7 Oct 2017, Srishti Sharma wrote: > The cast to pointer types in kfree is not needed and can be dropped. > Done using the following semantic by coccinelle. > > @r@ > type T,P; > T* x; > @@ > > kfree( > -(P *) > x ) > > Signed-off-by: Srishti Sharma> --- > drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 > > 1 file changed, 29 insertions(+), 29 deletions(-) > > diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c > b/drivers/staging/rtl8723bs/core/rtw_cmd.c > index 1843c44..e71e3ab 100644 > --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c > +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c > @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) > } > > /* free cmd_obj */ > - kfree((unsigned char *)pcmd); > + kfree(pcmd); > } > > > @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct > ndis_802_11_ssid *ssid, > > psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); > if (psurveyPara == NULL) { > - kfree((unsigned char *) ph2c); > + kfree(ph2c); > return _FAIL; > } > > @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 > *rateset) > > pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); > if (pbsetdataratepara == NULL) { > - kfree((u8 *) ph2c); > + kfree(ph2c); > res = _FAIL; > goto exit; > } > @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter > *padapter, struct cmd_obj *p > { > /* rtw_free_cmd_obj(pcmd); */ > kfree((unsigned char *) pcmd->parmbuf); This case didn't get updated, probably because Coccinelle didn't have access to enough type information. Try rerunning with --all-includes or --recursive-includes. You may also need to give some include path information (-I argument). julia > - kfree((unsigned char *) pcmd); > + kfree(pcmd); > } > > u8 rtw_createbss_cmd(struct adapter *padapter) > @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct > wlan_network *pnetwork) > psecnetwork = (struct wlan_bssid_ex *)>sec_bss; > if (psecnetwork == NULL) { > if (pcmd != NULL) > - kfree((unsigned char *)pcmd); > + kfree(pcmd); > > res = _FAIL; > > @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 > deauth_timeout_ms, bool enqueu > cmdobj = rtw_zmalloc(sizeof(*cmdobj)); > if (cmdobj == NULL) { > res = _FAIL; > - kfree((u8 *)param); > + kfree(param); > goto exit; > } > init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); > @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 > deauth_timeout_ms, bool enqueu > /* no need to enqueue, do the cmd hdl directly and free cmd > parameter */ > if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) > res = _FAIL; > - kfree((u8 *)param); > + kfree(param); > } > > exit: > @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum > NDIS_802_11_NETWORK_INFRAST > if (enqueue) { > ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); > if (ph2c == NULL) { > - kfree((u8 *)psetop); > + kfree(psetop); > res = _FAIL; > goto exit; > } > @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum > NDIS_802_11_NETWORK_INFRAST > res = rtw_enqueue_cmd(pcmdpriv, ph2c); > } else{ > setopmode_hdl(padapter, (u8 *)psetop); > - kfree((u8 *)psetop); > + kfree(psetop); > } > exit: > return res; > @@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct > sta_info *sta, u8 unicast_ > if (enqueue) { > ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); > if (ph2c == NULL) { > - kfree((u8 *) psetstakey_para); > + kfree(psetstakey_para); > res = _FAIL; > goto exit; > } > > psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); > if (psetstakey_rsp == NULL) { > - kfree((u8 *) ph2c); > - kfree((u8 *) psetstakey_para); > + kfree(ph2c); > + kfree(psetstakey_para); > res = _FAIL; > goto exit; > } > @@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct > sta_info *sta, u8 unicast_ > res = rtw_enqueue_cmd(pcmdpriv, ph2c); > } else{ >
Re: [Outreachy kernel] [PATCH] Staging: pi433: Fix the position of brace after if
On Sat, 7 Oct 2017, Srishti Sharma wrote: > Fix the position of the brace after if when it is on the next line > or when there is no space between them. Done using the following > semantic patch by coccinelle. As far as I can see, in practice, you only move up { from the line below. There is no occurrence of ){. So it would be better to say only what you actually did, and not what you additionally intended to do. Also, in the semantic patch, I'm not sure to see the point of the x=e; and f(...) part of the pattern. There should never ne a newline betwee the ) and { of an if, no matter what the if follows. julia > > @r1@ > position p1, p2; > identifier x,f; > expression e; > @@ > > ( > x=e; > | > f(...) > ) > > if(...)@p1 {@p2 > ... > } > > @script: python r2@ > p1 << r1.p1; > p2 << r1.p2; > @@ > > l1 = int (p1[0].line) > l2 = int (p2[0].line) > c1 = int (p1[0].column_end) > c2 = int (p2[0].column) > > if l1 == l2 and c1+1 == c2: > cocci.include_match(False) > > @r3@ > position r1.p1, r1.p2; > @@ > > if(... > - )@p1 > -{@p2 > +) { > ... > } > > Signed-off-by: Srishti Sharma> --- > drivers/staging/pi433/pi433_if.c | 54 > ++-- > 1 file changed, 18 insertions(+), 36 deletions(-) > > diff --git a/drivers/staging/pi433/pi433_if.c > b/drivers/staging/pi433/pi433_if.c > index d82c74d..d946838 100644 > --- a/drivers/staging/pi433/pi433_if.c > +++ b/drivers/staging/pi433/pi433_if.c > @@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct > pi433_tx_cfg *tx_cfg) > SET_CHECKED(rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc)); > > /* configure sync, if enabled */ > - if (tx_cfg->enable_sync == optionOn) > - { > + if (tx_cfg->enable_sync == optionOn) { > SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length)); > SET_CHECKED(rf69_set_sync_values(dev->spi, > tx_cfg->sync_pattern)); > } > @@ -408,8 +407,7 @@ pi433_receive(void *data) > if (retval) goto abort; /* wait was interrupted */ > > rf69_read_fifo(spi, (u8 *)_total, 1); > - if (bytes_total > dev->rx_buffer_size) > - { > + if (bytes_total > dev->rx_buffer_size) { > retval = -1; > goto abort; > } > @@ -509,16 +507,14 @@ pi433_tx_thread(void *data) > mutex_lock(>tx_fifo_lock); > > retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg)); > - if (retval != sizeof(tx_cfg)) > - { > + if (retval != sizeof(tx_cfg)) { > dev_dbg(device->dev, "reading tx_cfg from fifo failed: > got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) ); > mutex_unlock(>tx_fifo_lock); > continue; > } > > retval = kfifo_out(>tx_fifo, , sizeof(size_t)); > - if (retval != sizeof(size_t)) > - { > + if (retval != sizeof(size_t)) { > dev_dbg(device->dev, "reading msg size from fifo > failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) ); > mutex_unlock(>tx_fifo_lock); > continue; > @@ -650,8 +646,7 @@ pi433_tx_thread(void *data) > SET_CHECKED(rf69_set_mode(spi, standby)); > > /* everything sent? */ > - if ( kfifo_is_empty(>tx_fifo) ) > - { > + if (kfifo_is_empty(>tx_fifo)) { > abort: > if (rx_interrupted) > { > @@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t > size, loff_t *f_pos) > mutex_unlock(>rx_lock); > > /* if read was successful copy to user space*/ > - if (bytes_received > 0) > - { > + if (bytes_received > 0) { > retval = copy_to_user(buf, device->rx_buffer, bytes_received); > if (retval) > return -EFAULT; > @@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned > long arg) > switch (cmd) { > case PI433_IOC_RD_TX_CFG: > tmp = _IOC_SIZE(cmd); > - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) > - { > + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { > retval = -EINVAL; > break; > } > @@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned > long arg) > break; > case PI433_IOC_WR_TX_CFG: > tmp = _IOC_SIZE(cmd); > - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) > - { > + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { > retval = -EINVAL; > break; > } > @@ -917,8 +909,7 @@
Re: [Outreachy kernel] [PATCH] Staging: rtlwifi: phydm: Use setup_timer
On Sat, 7 Oct 2017, Srishti Sharma wrote: > Use setup_timer to combine initialization of a timer with the > initialization of the timer's function and data fields. Done > using the following semantic patch by coccinelle. > > @r@ > struct timer_list *l; > expression f, d; > @@ > > -init_timer(l); > +setup_timer(l,f,d); > ... > > ( > - l->function = f; > ... > - l->data = d; > | > - l->data = d; > ... > - l->function = f; > ) > > Signed-off-by: Srishti SharmaAcked-by: Julia Lawall > --- > drivers/staging/rtlwifi/phydm/phydm_interface.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.c > b/drivers/staging/rtlwifi/phydm/phydm_interface.c > index 102576a..aa1fb75 100644 > --- a/drivers/staging/rtlwifi/phydm/phydm_interface.c > +++ b/drivers/staging/rtlwifi/phydm/phydm_interface.c > @@ -189,9 +189,7 @@ void odm_initialize_timer(struct phy_dm_struct *dm, > struct timer_list *timer, > void *call_back_func, void *context, > const char *sz_id) > { > - init_timer(timer); > - timer->function = call_back_func; > - timer->data = (unsigned long)dm; > + setup_timer(timer, call_back_func, (unsigned long)dm); > /*mod_timer(timer, jiffies+RTL_MILISECONDS_TO_JIFFIES(10)); */ > } > > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups > "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to outreachy-kernel+unsubscr...@googlegroups.com. > To post to this group, send email to outreachy-ker...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/outreachy-kernel/1507397185-6139-1-git-send-email-srishtishar%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: rtlwifi: phydm: Use setup_timer
Use setup_timer to combine initialization of a timer with the initialization of the timer's function and data fields. Done using the following semantic patch by coccinelle. @r@ struct timer_list *l; expression f, d; @@ -init_timer(l); +setup_timer(l,f,d); ... ( - l->function = f; ... - l->data = d; | - l->data = d; ... - l->function = f; ) Signed-off-by: Srishti Sharma--- drivers/staging/rtlwifi/phydm/phydm_interface.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_interface.c b/drivers/staging/rtlwifi/phydm/phydm_interface.c index 102576a..aa1fb75 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_interface.c +++ b/drivers/staging/rtlwifi/phydm/phydm_interface.c @@ -189,9 +189,7 @@ void odm_initialize_timer(struct phy_dm_struct *dm, struct timer_list *timer, void *call_back_func, void *context, const char *sz_id) { - init_timer(timer); - timer->function = call_back_func; - timer->data = (unsigned long)dm; + setup_timer(timer, call_back_func, (unsigned long)dm); /*mod_timer(timer, jiffies+RTL_MILISECONDS_TO_JIFFIES(10)); */ } -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: pi433: Fix the position of brace after if
Fix the position of the brace after if when it is on the next line or when there is no space between them. Done using the following semantic patch by coccinelle. @r1@ position p1, p2; identifier x,f; expression e; @@ ( x=e; | f(...) ) if(...)@p1 {@p2 ... } @script: python r2@ p1 << r1.p1; p2 << r1.p2; @@ l1 = int (p1[0].line) l2 = int (p2[0].line) c1 = int (p1[0].column_end) c2 = int (p2[0].column) if l1 == l2 and c1+1 == c2: cocci.include_match(False) @r3@ position r1.p1, r1.p2; @@ if(... - )@p1 -{@p2 +) { ... } Signed-off-by: Srishti Sharma--- drivers/staging/pi433/pi433_if.c | 54 ++-- 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index d82c74d..d946838 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -285,8 +285,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct pi433_tx_cfg *tx_cfg) SET_CHECKED(rf69_set_crc_enable (dev->spi, tx_cfg->enable_crc)); /* configure sync, if enabled */ - if (tx_cfg->enable_sync == optionOn) - { + if (tx_cfg->enable_sync == optionOn) { SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length)); SET_CHECKED(rf69_set_sync_values(dev->spi, tx_cfg->sync_pattern)); } @@ -408,8 +407,7 @@ pi433_receive(void *data) if (retval) goto abort; /* wait was interrupted */ rf69_read_fifo(spi, (u8 *)_total, 1); - if (bytes_total > dev->rx_buffer_size) - { + if (bytes_total > dev->rx_buffer_size) { retval = -1; goto abort; } @@ -509,16 +507,14 @@ pi433_tx_thread(void *data) mutex_lock(>tx_fifo_lock); retval = kfifo_out(>tx_fifo, _cfg, sizeof(tx_cfg)); - if (retval != sizeof(tx_cfg)) - { + if (retval != sizeof(tx_cfg)) { dev_dbg(device->dev, "reading tx_cfg from fifo failed: got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) ); mutex_unlock(>tx_fifo_lock); continue; } retval = kfifo_out(>tx_fifo, , sizeof(size_t)); - if (retval != sizeof(size_t)) - { + if (retval != sizeof(size_t)) { dev_dbg(device->dev, "reading msg size from fifo failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) ); mutex_unlock(>tx_fifo_lock); continue; @@ -650,8 +646,7 @@ pi433_tx_thread(void *data) SET_CHECKED(rf69_set_mode(spi, standby)); /* everything sent? */ - if ( kfifo_is_empty(>tx_fifo) ) - { + if (kfifo_is_empty(>tx_fifo)) { abort: if (rx_interrupted) { @@ -705,8 +700,7 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos) mutex_unlock(>rx_lock); /* if read was successful copy to user space*/ - if (bytes_received > 0) - { + if (bytes_received > 0) { retval = copy_to_user(buf, device->rx_buffer, bytes_received); if (retval) return -EFAULT; @@ -806,8 +800,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) switch (cmd) { case PI433_IOC_RD_TX_CFG: tmp = _IOC_SIZE(cmd); - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) - { + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { retval = -EINVAL; break; } @@ -823,8 +816,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) break; case PI433_IOC_WR_TX_CFG: tmp = _IOC_SIZE(cmd); - if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) ) - { + if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) { retval = -EINVAL; break; } @@ -917,8 +909,7 @@ static int pi433_open(struct inode *inode, struct file *filp) if (!device->rx_buffer) { device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL); - if (!device->rx_buffer) - { + if (!device->rx_buffer) { dev_dbg(device->dev, "open/ENOMEM\n"); return -ENOMEM; } @@ -926,8 +917,7 @@ static int pi433_open(struct inode *inode, struct file *filp) device->users++; instance = kzalloc(sizeof(*instance), GFP_KERNEL); - if (!instance) - { +
Re: [Outreachy kernel] [PATCH] Staging: media: atomisp: pci: Eliminate use of typedefs for struct
On Sat, 7 Oct 2017, Srishti Sharma wrote: > The use of typedefs for struct is discouraged, and hence can be > eliminated. Done using the following semantic patch by coccinelle. > > @r1@ > type T; > @@ > > typedef struct {...} T; > > @script: python p@ > T << r1.T; > T1; > @@ > > if T[-2:] == "_t" or T[-2:] == "_T": > coccinelle.T1 = T[:-2] > else: > coccinelle.T1 = T > > print T, T1 > @r2@ > type r1.T; > identifier p.T1; > @@ > > - typedef > struct > + T1 > { > ... > } > - T > ; > > @r3@ > type r1.T; > identifier p.T1; > @@ > > - T > + struct T1 > > Signed-off-by: Srishti SharmaAcked-by: Julia Lawall > --- > .../media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c | 6 > +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git > a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c > > b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c > index d9178e8..6d9bceb 100644 > --- > a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c > +++ > b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c > @@ -37,7 +37,7 @@ more details. > #include "ia_css_spctrl.h" > #include "ia_css_debug.h" > > -typedef struct { > +struct spctrl_context_info { > struct ia_css_sp_init_dmem_cfg dmem_config; > uint32_tspctrl_config_dmem_addr; /** location of dmem_cfg in > SP dmem */ > uint32_tspctrl_state_dmem_addr; > @@ -45,9 +45,9 @@ typedef struct { > hrt_vaddresscode_addr; /* sp firmware location in host > mem-DDR*/ > uint32_tcode_size; > char *program_name; /* used in case of PLATFORM_SIM */ > -} spctrl_context_info; > +}; > > -static spctrl_context_info spctrl_cofig_info[N_SP_ID]; > +static struct spctrl_context_info spctrl_cofig_info[N_SP_ID]; > static bool spctrl_loaded[N_SP_ID] = {0}; > > /* Load firmware */ > -- > 2.7.4 > > -- > You received this message because you are subscribed to the Google Groups > "outreachy-kernel" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to outreachy-kernel+unsubscr...@googlegroups.com. > To post to this group, send email to outreachy-ker...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/outreachy-kernel/1507384322-16584-1-git-send-email-srishtishar%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: media: atomisp: pci: Eliminate use of typedefs for struct
The use of typedefs for struct is discouraged, and hence can be eliminated. Done using the following semantic patch by coccinelle. @r1@ type T; @@ typedef struct {...} T; @script: python p@ T << r1.T; T1; @@ if T[-2:] == "_t" or T[-2:] == "_T": coccinelle.T1 = T[:-2] else: coccinelle.T1 = T print T, T1 @r2@ type r1.T; identifier p.T1; @@ - typedef struct + T1 { ... } - T ; @r3@ type r1.T; identifier p.T1; @@ - T + struct T1 Signed-off-by: Srishti Sharma--- .../media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c index d9178e8..6d9bceb 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/spctrl/src/spctrl.c @@ -37,7 +37,7 @@ more details. #include "ia_css_spctrl.h" #include "ia_css_debug.h" -typedef struct { +struct spctrl_context_info { struct ia_css_sp_init_dmem_cfg dmem_config; uint32_tspctrl_config_dmem_addr; /** location of dmem_cfg in SP dmem */ uint32_tspctrl_state_dmem_addr; @@ -45,9 +45,9 @@ typedef struct { hrt_vaddresscode_addr; /* sp firmware location in host mem-DDR*/ uint32_tcode_size; char *program_name; /* used in case of PLATFORM_SIM */ -} spctrl_context_info; +}; -static spctrl_context_info spctrl_cofig_info[N_SP_ID]; +static struct spctrl_context_info spctrl_cofig_info[N_SP_ID]; static bool spctrl_loaded[N_SP_ID] = {0}; /* Load firmware */ -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: rtl8723bs: core: rtw_cmd: Remove cast to pointer types in kfree
The cast to pointer types in kfree is not needed and can be dropped. Done using the following semantic by coccinelle. @r@ type T,P; T* x; @@ kfree( -(P *) x ) Signed-off-by: Srishti Sharma--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 58 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 1843c44..e71e3ab 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -408,7 +408,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) } /* free cmd_obj */ - kfree((unsigned char *)pcmd); + kfree(pcmd); } @@ -619,7 +619,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, psurveyPara = rtw_zmalloc(sizeof(struct sitesurvey_parm)); if (psurveyPara == NULL) { - kfree((unsigned char *) ph2c); + kfree(ph2c); return _FAIL; } @@ -689,7 +689,7 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) pbsetdataratepara = rtw_zmalloc(sizeof(struct setdatarate_parm)); if (pbsetdataratepara == NULL) { - kfree((u8 *) ph2c); + kfree(ph2c); res = _FAIL; goto exit; } @@ -707,7 +707,7 @@ void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *p { /* rtw_free_cmd_obj(pcmd); */ kfree((unsigned char *) pcmd->parmbuf); - kfree((unsigned char *) pcmd); + kfree(pcmd); } u8 rtw_createbss_cmd(struct adapter *padapter) @@ -847,7 +847,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecnetwork = (struct wlan_bssid_ex *)>sec_bss; if (psecnetwork == NULL) { if (pcmd != NULL) - kfree((unsigned char *)pcmd); + kfree(pcmd); res = _FAIL; @@ -955,7 +955,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu cmdobj = rtw_zmalloc(sizeof(*cmdobj)); if (cmdobj == NULL) { res = _FAIL; - kfree((u8 *)param); + kfree(param); goto exit; } init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); @@ -964,7 +964,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) res = _FAIL; - kfree((u8 *)param); + kfree(param); } exit: @@ -990,7 +990,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST if (enqueue) { ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { - kfree((u8 *)psetop); + kfree(psetop); res = _FAIL; goto exit; } @@ -999,7 +999,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST res = rtw_enqueue_cmd(pcmdpriv, ph2c); } else{ setopmode_hdl(padapter, (u8 *)psetop); - kfree((u8 *)psetop); + kfree(psetop); } exit: return res; @@ -1042,15 +1042,15 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ if (enqueue) { ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { - kfree((u8 *) psetstakey_para); + kfree(psetstakey_para); res = _FAIL; goto exit; } psetstakey_rsp = rtw_zmalloc(sizeof(struct set_stakey_rsp)); if (psetstakey_rsp == NULL) { - kfree((u8 *) ph2c); - kfree((u8 *) psetstakey_para); + kfree(ph2c); + kfree(psetstakey_para); res = _FAIL; goto exit; } @@ -1061,7 +1061,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ res = rtw_enqueue_cmd(pcmdpriv, ph2c); } else{ set_stakey_hdl(padapter, (u8 *)psetstakey_para); - kfree((u8 *) psetstakey_para); + kfree(psetstakey_para); } exit: return res; @@ -1091,15 +1091,15 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu psetstakey_para = rtw_zmalloc(sizeof(struct set_stakey_parm)); if
Business Deal
My name is Huyen Vo Ha. Can I trust you to handle a Business Deal in my office?. If yes, reply for more understanding. Regards, Huyen Vo Ha AVISO DE SEGURIDAD ~ Los datos contenidos en el mensaje precedente puede tener informacinnn de propiedad exclusiva de la Direccinnn Nacional de Vialidad. En virtud de ello, se otorga a este el carcter de CONFIDENCIAL y se impone a los receptores del mismo la obligacinnn de resguardar y proteger su difusinnn y de no divulgarlo sin autorizacinnn. Asimismo, si hubiere recibido este por error deber comunicarlo v email a seguridadinformat...@vialidad.gob.ar, o por fax al +54(11)4343-9800, y proceder a destruir el mensaje en forma inmediata. Atte. DIRECCIN NACIONAL DE VIALIDAD. ~ SECURITY WARNING ~ All content on this message is the exclusive property of Direccion Nacional de Vialidad. Since the content of the message is classified as confidential, it may not be reproduced, duplicated, copied, or otherwise exploited for any commercial purpose without express written consent. If you have received this mail by mistake, you must contact via email to seguridadinformat...@vialidad.gob.ar, or by fax to +54 (11) 4343-9800 and destroy the message immediately. Sincerely DIRECCIN NACIONAL DE VIALIDAD. Este correo electrónico puede contener material confidencial y privilegiado para el uso exclusivo del destinatario. Cualquier revisión, uso, distribución o divulgación por parte de terceros está estrictamente prohibido. Si no es el destinatario (o está autorizado a recibirlo para el destinatario), comuníquese con el remitente por correo electrónico de respuesta y elimine todas las copias de este mensaje. This email may contain confidential and privileged material for the sole use of the intended recipient. Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply email and delete all copies of this message. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel