[PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse
The third argument to function kportal_memhog_alloc is expected to be gfp_t whereas the actual argument was unsigned int. Fix this by explicitly typecasting to gfp_t Signed-off-by: Niranjan Dighe --- drivers/staging/lustre/lustre/libcfs/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 96d9d46..9c79f6e 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, /* XXX The ioc_flags is not GFP flags now, need to be fixed */ err = kportal_memhog_alloc(pfile->private_data, data->ioc_count, - data->ioc_flags); + (__force gfp_t)data->ioc_flags); if (err != 0) kportal_memhog_free(pfile->private_data); } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse
On Tue, Dec 22, 2015 at 5:14 AM, Greg Kroah-Hartman wrote: > On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote: >> The third argument to function kportal_memhog_alloc is expected to >> be gfp_t whereas the actual argument was unsigned int. Fix this by >> explicitly typecasting to gfp_t >> >> Signed-off-by: Niranjan Dighe >> --- >> drivers/staging/lustre/lustre/libcfs/module.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c >> b/drivers/staging/lustre/lustre/libcfs/module.c >> index 96d9d46..9c79f6e 100644 >> --- a/drivers/staging/lustre/lustre/libcfs/module.c >> +++ b/drivers/staging/lustre/lustre/libcfs/module.c >> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file >> *pfile, unsigned long cmd, >> /* XXX The ioc_flags is not GFP flags now, need to be >> fixed */ >> err = kportal_memhog_alloc(pfile->private_data, >> data->ioc_count, >> -data->ioc_flags); >> + (__force gfp_t)data->ioc_flags); > > No, please fix the type to be correct properly, like the comment says > needs to be done. > > thanks, > > greg k-h Hello Greg, I could see that the ioc_flags member of the struct libcfs_ioctl_data is used as gfp_t only in the case of the ioctl IOC_LIBCFS_MEMHOG. I can think of following ways to correct it - 1. Create a union that has 2 different types encapsulated, something like this - union { __u32 ioc_flags; gfp_t alloc_flags; }flags; Because, the ioc_flags seems to be used in different contexts at different places throughout the drivers/staging/lustre directory. 2. Is it OK to hardcode the appropriate gfp_t flags for the IOC_LIBCFS_MEMHOG, as the userspace seems to be taking the decision about the page allocation zone/strategy, is this what is intended? Regards, Niranjan Dighe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse
On Wed, Dec 23, 2015 at 3:34 AM, Dilger, Andreas wrote: > On 2015/12/22, 06:05, "Niranjan Dighe" wrote: > >>On Tue, Dec 22, 2015 at 5:14 AM, Greg Kroah-Hartman >> wrote: >>> On Wed, Dec 09, 2015 at 10:38:13PM +0530, Niranjan Dighe wrote: >>>> The third argument to function kportal_memhog_alloc is expected to >>>> be gfp_t whereas the actual argument was unsigned int. Fix this by >>>> explicitly typecasting to gfp_t >>>> >>>> Signed-off-by: Niranjan Dighe >>>> --- >>>> drivers/staging/lustre/lustre/libcfs/module.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/staging/lustre/lustre/libcfs/module.c >>>>b/drivers/staging/lustre/lustre/libcfs/module.c >>>> index 96d9d46..9c79f6e 100644 >>>> --- a/drivers/staging/lustre/lustre/libcfs/module.c >>>> +++ b/drivers/staging/lustre/lustre/libcfs/module.c >>>> @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file >>>>*pfile, unsigned long cmd, >>>> /* XXX The ioc_flags is not GFP flags now, need >>>>to be fixed */ >>>> err = kportal_memhog_alloc(pfile->private_data, >>>> data->ioc_count, >>>> -data->ioc_flags); >>>> + (__force gfp_t)data->ioc_flags); >>> >>> No, please fix the type to be correct properly, like the comment says >>> needs to be done. >>> >>> thanks, >>> >>> greg k-h >> >>Hello Greg, >> >>I could see that the ioc_flags member of the struct libcfs_ioctl_data >>is used as gfp_t only in the >>case of the ioctl IOC_LIBCFS_MEMHOG. I can think of following ways to >>correct it - >> >>1. Create a union that has 2 different types encapsulated, something like >>this - >>union { >>__u32 ioc_flags; >>gfp_t alloc_flags; >>}flags; >>Because, the ioc_flags seems to be used in different contexts at >>different places throughout the >>drivers/staging/lustre directory. >> >>2. Is it OK to hardcode the appropriate gfp_t flags for the >>IOC_LIBCFS_MEMHOG, as the userspace >>seems to be taking the decision about the page allocation >>zone/strategy, is this what is intended? > > The memhog functionality is used to introduce memory pressure on a client > or server during operation to test error handling as well as memory > allocation deadlocks (e.g. GFP_KERNEL used where GFP_NOFS should be used). > There are other ways to do this in the kernel today, so all of the memhog > code could just be deleted I think. > > This looks like kportal_memhog_alloc(), kportal_memhog_free(), > IOC_LIBCFS_MEMHOG, and struct libcfs_device_userstate could be removed. > > > Cheers, Andreas > Thanks Andreas, I will send out a separate patch with the cleanup as you suggested. Regards, Niranjan ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: lustre: Fix 'unexpected unlock' warning generated by sparse
Added annotation '__must_hold' to function ksocknal_send_keepalive_locked which unlocks the lock ksocknal_data.ksnd_global_lock. As this lock is not acquired in the current function, sparse warns about context imbalance Signed-off-by: Niranjan Dighe --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 477b385..29525a0 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -2336,6 +2336,7 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer) static int ksocknal_send_keepalive_locked(ksock_peer_t *peer) +__must_hold(&ksocknal_data.ksnd_global_lock) { ksock_sched_t *sched; ksock_conn_t *conn; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: lustre: Fix 'unexpected unlock' warning generated by sparse
On Thu, Feb 4, 2016 at 3:53 AM, Greg Kroah-Hartman wrote: > On Sun, Jan 03, 2016 at 08:27:04AM +0530, Niranjan Dighe wrote: >> Added annotation '__must_hold' to function ksocknal_send_keepalive_locked >> which unlocks the lock ksocknal_data.ksnd_global_lock. As this lock is >> not acquired in the current function, sparse warns about context imbalance >> >> Signed-off-by: Niranjan Dighe >> --- >> drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 1 + >> 1 file changed, 1 insertion(+) > > Doesn't apply to my tree :( Sorry about this Greg, I will recreate it on the latest staging-next and resend. Thanks, Niranjan Dighe ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse
Fixed the following warning reported by sparse about typecasting. A userspace pointer was being typecasted by simply (char *) which causes sparse to give the following warning - warning: cast removes address space of expression Fixed it by adding __user annotation to the typecasting. Signed-off-by: Niranjan Dighe --- drivers/staging/lustre/lnet/selftest/console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 366211e..64b6a70 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -1461,9 +1461,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg, sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0]; srpc_stat = (srpc_counters_t __user *) - ((char *)sfwk_stat + sizeof(*sfwk_stat)); + ((char __user *)sfwk_stat + sizeof(*sfwk_stat)); lnet_stat = (lnet_counters_t __user *) - ((char *)srpc_stat + sizeof(*srpc_stat)); + ((char __user *)srpc_stat + sizeof(*srpc_stat)); if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) || copy_to_user(srpc_stat, &rep->str_rpc, sizeof(*srpc_stat)) || -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: lustre/lnet: Fix wrong type casting warning generated by sparse
On Sun, Feb 14, 2016 at 3:19 AM, Dan Carpenter wrote: > On Sat, Feb 13, 2016 at 11:34:35PM +0530, Niranjan Dighe wrote: >> diff --git a/drivers/staging/lustre/lnet/selftest/console.c >> b/drivers/staging/lustre/lnet/selftest/console.c >> index 366211e..64b6a70 100644 >> --- a/drivers/staging/lustre/lnet/selftest/console.c >> +++ b/drivers/staging/lustre/lnet/selftest/console.c >> @@ -1461,9 +1461,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg, >> >> sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0]; >> srpc_stat = (srpc_counters_t __user *) >> - ((char *)sfwk_stat + sizeof(*sfwk_stat)); >> + ((char __user *)sfwk_stat + >> sizeof(*sfwk_stat)); > > This is uglier than necessary. Do it either like this: > > srpc_stat = (void __user *)sfwk_stat + sizeof(*sfwk_stat); > > Or probably it's actually nicer to say: > > srpc_stat = sfwk_stat + 1; > > regards, > dan carpenter > Yes, thanks Dan, I will send out a new patch. Please discard this one. ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: lustre/lnet: Fix wrong typecasting warning generated by sparse
Fix the following warning generated about type casting by sparse warning: cast removes address space of expression The current implementation casts the structure pointers with (char *) without __user annotation and then adds sizeof struct to it, thereby generating the sparse warning. Fixed this by removing the unnecessary char pointer type cast. Signed-off-by: Niranjan Dighe --- drivers/staging/lustre/lnet/selftest/console.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 366211e..bc236c9 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -1460,10 +1460,8 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg, return 0; sfwk_stat = (sfw_counters_t __user *)&ent_up->rpe_payload[0]; - srpc_stat = (srpc_counters_t __user *) - ((char *)sfwk_stat + sizeof(*sfwk_stat)); - lnet_stat = (lnet_counters_t __user *) - ((char *)srpc_stat + sizeof(*srpc_stat)); + srpc_stat = (srpc_counters_t __user *)(sfwk_stat + 1); + lnet_stat = (lnet_counters_t __user *)(srpc_stat + 1); if (copy_to_user(sfwk_stat, &rep->str_fw, sizeof(*sfwk_stat)) || copy_to_user(srpc_stat, &rep->str_rpc, sizeof(*srpc_stat)) || -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Staging: slicoss: Fix checkpatch.pl issues
The following files had coding style issues that I tried to address. It was mostly about lines spanning more than 80 characters. Signed-off-by: Niranjan Dighe diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 3104cb0..2161bdb 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -98,7 +98,8 @@ #include "slic.h" static uint slic_first_init = 1; -static char *slic_banner = "Alacritech SLIC Technology(tm) Server and Storage Accelerator (Non-Accelerated)"; +static char *slic_banner = "Alacritech SLIC Technology(tm) Server " + "and Storage Accelerator (Non-Accelerated)"; static char *slic_proc_version = "2.0.351 2006/07/14 12:26:00"; @@ -755,10 +756,10 @@ static bool slic_mac_filter(struct adapter *adapter, while (mcaddr) { if (ether_addr_equal(mcaddr->address, -ether_frame->ether_dhost)) { - adapter->rcv_multicasts++; - netdev->stats.multicast++; - return true; + ether_frame->ether_dhost)) { + adapter->rcv_multicasts++; + netdev->stats.multicast++; + return true; } mcaddr = mcaddr->next; } @@ -2561,8 +2562,9 @@ static int slic_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) DBG_IOCTL("slic_ioctl SIOCSLIC_TRACE_DUMP\n"); if (copy_from_user(data, rq->ifr_data, 28)) { - PRINT_ERROR - ("slic: copy_from_user FAILED getting initial simba param\n"); + PRINT_ERROR( + "slic: copy_from_user FAILED getting initial simba param\n" + ); return -EFAULT; } @@ -2576,8 +2578,9 @@ static int slic_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) } else if ((tracemon_request == SLIC_DUMP_REQUESTED) || (tracemon_request == SLIC_DUMP_IN_PROGRESS)) { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested but already in progress... ignore\n"); + PRINT_ERROR( + "ATK Diagnostic Trace Dump Requested but already in progress... ignore\n" + ); } else { PRINT_ERROR ("ATK Diagnostic Trace Dump Requested\n"); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: rtl8188eu: replace kzalloc and memcpy by kmemdup
This was generated by 'make coccicheck' using scripts at scripts/coccinelle/api/memdup.cocci. Signed-off-by: Niranjan Dighe diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 86d955f..be9e34a 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -5431,15 +5431,14 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) goto exit; } - ptxBeacon_parm = kzalloc(sizeof(struct wlan_bssid_ex), GFP_KERNEL); + ptxBeacon_parm = kmemdup(&(pmlmeinfo->network), + sizeof(struct wlan_bssid_ex), GFP_KERNEL); if (ptxBeacon_parm == NULL) { kfree(ph2c); res = _FAIL; goto exit; } - memcpy(ptxBeacon_parm, &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); - len_diff = update_hidden_ssid(ptxBeacon_parm->IEs+_BEACON_IE_OFFSET_, ptxBeacon_parm->IELength-_BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: slicoss: Fix checkpatch.pl issues
Removed unused block of code guarded by #ifdef SLIC_TRACE_DUMP_ENABLED And removed redundant static char *slic_banner and replaced actual string in place of format string. Signed-off-by: Niranjan Dighe diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 3104cb0..f3110f7 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -98,7 +98,6 @@ #include "slic.h" static uint slic_first_init = 1; -static char *slic_banner = "Alacritech SLIC Technology(tm) Server and Storage Accelerator (Non-Accelerated)"; static char *slic_proc_version = "2.0.351 2006/07/14 12:26:00"; @@ -2553,41 +2552,6 @@ static int slic_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) slic_intagg_set(adapter, intagg); return 0; -#ifdef SLIC_TRACE_DUMP_ENABLED - case SIOCSLICTRACEDUMP: - { - u32 value; - - DBG_IOCTL("slic_ioctl SIOCSLIC_TRACE_DUMP\n"); - - if (copy_from_user(data, rq->ifr_data, 28)) { - PRINT_ERROR - ("slic: copy_from_user FAILED getting initial simba param\n"); - return -EFAULT; - } - - value = data[0]; - if (tracemon_request == SLIC_DUMP_DONE) { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested\n"); - tracemon_request = SLIC_DUMP_REQUESTED; - tracemon_request_type = value; - tracemon_timestamp = jiffies; - } else if ((tracemon_request == SLIC_DUMP_REQUESTED) || - (tracemon_request == - SLIC_DUMP_IN_PROGRESS)) { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested but already in progress... ignore\n"); - } else { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested\n"); - tracemon_request = SLIC_DUMP_REQUESTED; - tracemon_request_type = value; - tracemon_timestamp = jiffies; - } - return 0; - } -#endif case SIOCETHTOOL: if (copy_from_user(&ecmd, rq->ifr_data, sizeof(ecmd))) return -EFAULT; @@ -3081,7 +3045,8 @@ static int slic_entry_probe(struct pci_dev *pcidev, return err; if (did_version++ == 0) { - dev_info(&pcidev->dev, "%s\n", slic_banner); + dev_info(&pcidev->dev, + "Alacritech SLIC Technology(tm) Server and Storage Accelerator (Non-Accelerated)\n"); dev_info(&pcidev->dev, "%s\n", slic_proc_version); } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 1/2] Staging: slicoss: Remove redundant and disabled code block
Removing code guarded by undefined macro SLIC_TRACE_DUMP_ENABLED Signed-off-by: Niranjan Dighe diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index 3104cb0..c2bda1d 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -2553,41 +2553,6 @@ static int slic_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) slic_intagg_set(adapter, intagg); return 0; -#ifdef SLIC_TRACE_DUMP_ENABLED - case SIOCSLICTRACEDUMP: - { - u32 value; - - DBG_IOCTL("slic_ioctl SIOCSLIC_TRACE_DUMP\n"); - - if (copy_from_user(data, rq->ifr_data, 28)) { - PRINT_ERROR - ("slic: copy_from_user FAILED getting initial simba param\n"); - return -EFAULT; - } - - value = data[0]; - if (tracemon_request == SLIC_DUMP_DONE) { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested\n"); - tracemon_request = SLIC_DUMP_REQUESTED; - tracemon_request_type = value; - tracemon_timestamp = jiffies; - } else if ((tracemon_request == SLIC_DUMP_REQUESTED) || - (tracemon_request == - SLIC_DUMP_IN_PROGRESS)) { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested but already in progress... ignore\n"); - } else { - PRINT_ERROR - ("ATK Diagnostic Trace Dump Requested\n"); - tracemon_request = SLIC_DUMP_REQUESTED; - tracemon_request_type = value; - tracemon_timestamp = jiffies; - } - return 0; - } -#endif case SIOCETHTOOL: if (copy_from_user(&ecmd, rq->ifr_data, sizeof(ecmd))) return -EFAULT; -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2 2/2] Staging: slicoss: Get rid of redundant pointer variable
Replace string directly in place of format string and remove pointer variable which was used just once. Signed-off-by: Niranjan Dighe diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c index c2bda1d..f3110f7 100644 --- a/drivers/staging/slicoss/slicoss.c +++ b/drivers/staging/slicoss/slicoss.c @@ -98,7 +98,6 @@ #include "slic.h" static uint slic_first_init = 1; -static char *slic_banner = "Alacritech SLIC Technology(tm) Server and Storage Accelerator (Non-Accelerated)"; static char *slic_proc_version = "2.0.351 2006/07/14 12:26:00"; @@ -3046,7 +3045,8 @@ static int slic_entry_probe(struct pci_dev *pcidev, return err; if (did_version++ == 0) { - dev_info(&pcidev->dev, "%s\n", slic_banner); + dev_info(&pcidev->dev, + "Alacritech SLIC Technology(tm) Server and Storage Accelerator (Non-Accelerated)\n"); dev_info(&pcidev->dev, "%s\n", slic_proc_version); } -- 1.9.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel