Passing uninitialised local variable
Hello everyone, I recently found that a local variable in passed uninitialised to the function at drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:2950 u32 var; err = brcmf_fil_iovar_int_get(ifp, "dtim_assoc", ); if (err) { brcmf_err("wl dtim_assoc failed (%d)\n", err); goto update_bss_info_out; } dtim_period = (u8)var; Now, the brcmf_fil_iovar_int_get() is defined as: s32 brcmf_fil_iovar_int_get(struct brcmf_if *ifp, char *name, u32 *data) { __le32 data_le = cpu_to_le32(*data); s32 err; err = brcmf_fil_iovar_data_get(ifp, name, _le, sizeof(data_le)); if (err == 0) *data = le32_to_cpu(data_le); return err; } We can cleary see that 'var' in used uninitialised in the very first line which is an undefined behavior. So, what could be a possible fix for the above ? I'm not sure initialising 'var' to 0 would be the correct solution. -- Thanks Himanshu Jha
Re: [PATCH] drivers: net: wireless: ath: ath9: dfs: remove VLA usage
On Fri, Mar 09, 2018 at 02:30:12PM +0200, Andreas Christoforou wrote: > The kernel would like to have all stack VLA usage removed. > > Signed-off-by: Andreas Christoforou <andreaschrist...@gmail.com> > --- > drivers/net/wireless/ath/ath9k/dfs.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/wireless/ath/ath9k/dfs.c > b/drivers/net/wireless/ath/ath9k/dfs.c > index 6fee9a4..cfb0f84 100644 > --- a/drivers/net/wireless/ath/ath9k/dfs.c > +++ b/drivers/net/wireless/ath/ath9k/dfs.c > @@ -41,7 +41,6 @@ static const int BIN_DELTA_MAX = 10; > > /* we need at least 3 deltas / 4 samples for a reliable chirp detection */ > #define NUM_DIFFS 3 > -static const int FFT_NUM_SAMPLES = (NUM_DIFFS + 1); Are you sure it is correct ? Look for other users of "FFT_NUM_SAMPLES". > /* Threshold for difference of delta peaks */ > static const int MAX_DIFF= 2; > @@ -101,7 +100,7 @@ static bool ath9k_check_chirping(struct ath_softc *sc, u8 > *data, >int datalen, bool is_ctl, bool is_ext) > { > int i; > - int max_bin[FFT_NUM_SAMPLES]; > + int max_bin[NUM_DIFFS + 1]; > struct ath_hw *ah = sc->sc_ah; > struct ath_common *common = ath9k_hw_common(ah); > int prev_delta; Always compile test the driver before sending a patch. Also, patch title seems incorrect *ath9k* himanshu@himanshu-Vostro-3559:~/linux-next$ git log --oneline drivers/net/wireless/ath/ath9k/dfs.c 626ab67 ath9k: dfs: use swap macro in ath9k_check_chirping 50c8cd4 ath9k: remove cast to void pointer 8fc2b61 ath9k: DFS - add pulse chirp detection for FCC -- Thanks Himanshu Jha
[PATCH v2] brcmfmac: Use zeroing memory allocator than allocator/memset
Use dma_zalloc_coherent for allocating zeroed memory and remove unnecessary memset function. Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci Suggested-by: Luis R. Rodriguez <mcg...@kernel.org> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- v2: -corrected the patch to be applied into the branch without corruption .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 3c87157..8752707 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1251,14 +1251,14 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) u64 address; u32 addr; - devinfo->shared.scratch = dma_alloc_coherent(>pdev->dev, - BRCMF_DMA_D2H_SCRATCH_BUF_LEN, - >shared.scratch_dmahandle, GFP_KERNEL); + devinfo->shared.scratch = + dma_zalloc_coherent(>pdev->dev, + BRCMF_DMA_D2H_SCRATCH_BUF_LEN, + >shared.scratch_dmahandle, + GFP_KERNEL); if (!devinfo->shared.scratch) goto fail; - memset(devinfo->shared.scratch, 0, BRCMF_DMA_D2H_SCRATCH_BUF_LEN); - addr = devinfo->shared.tcm_base_address + BRCMF_SHARED_DMA_SCRATCH_ADDR_OFFSET; address = (u64)devinfo->shared.scratch_dmahandle; @@ -1268,14 +1268,14 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) BRCMF_SHARED_DMA_SCRATCH_LEN_OFFSET; brcmf_pcie_write_tcm32(devinfo, addr, BRCMF_DMA_D2H_SCRATCH_BUF_LEN); - devinfo->shared.ringupd = dma_alloc_coherent(>pdev->dev, - BRCMF_DMA_D2H_RINGUPD_BUF_LEN, - >shared.ringupd_dmahandle, GFP_KERNEL); + devinfo->shared.ringupd = + dma_zalloc_coherent(>pdev->dev, + BRCMF_DMA_D2H_RINGUPD_BUF_LEN, + >shared.ringupd_dmahandle, + GFP_KERNEL); if (!devinfo->shared.ringupd) goto fail; - memset(devinfo->shared.ringupd, 0, BRCMF_DMA_D2H_RINGUPD_BUF_LEN); - addr = devinfo->shared.tcm_base_address + BRCMF_SHARED_DMA_RINGUPD_ADDR_OFFSET; address = (u64)devinfo->shared.ringupd_dmahandle; -- 2.7.4
Re: brcmfmac: Use zeroing memory allocator than allocator/memset
On Mon, Jan 08, 2018 at 05:23:22PM +, Kalle Valo wrote: > Himanshu Jha <himanshujha199...@gmail.com> wrote: > > > Use dma_zalloc_coherent for allocating zeroed > > memory and remove unnecessary memset function. > > > > Done using Coccinelle. > > Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci > > 0-day tested with no failures. > > > > Suggested-by: Luis R. Rodriguez <mcg...@kernel.org> > > Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> > > Reviewed-by: Andy Shevchenko <andy.shevche...@gmail.com> > > Failed to apply: > > fatal: corrupt patch at line 29 > error: could not build fake ancestor > Applying: brcmfmac: Use zeroing memory allocator than allocator/memset > Patch failed at 0001 brcmfmac: Use zeroing memory allocator than > allocator/memset > The copy of the patch that failed is found in: .git/rebase-apply/patch > > Patch set to Changes Requested. Sorry! That failed because I manually adjusted the arguments to prevent 80 character limit in the patch generated. I will rebase and send v2 with updates. -- Thanks Himanshu Jha
[PATCH] brcmfmac: Use zeroing memory allocator than allocator/memset
Use dma_zalloc_coherent for allocating zeroed memory and remove unnecessary memset function. Done using Coccinelle. Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci 0-day tested with no failures. Suggested-by: Luis R. Rodriguez <mcg...@kernel.org> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- .../net/wireless/broadcom/brcm80211/brcmfmac/pcie.c| 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 3c87157..bdef2ac 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1251,14 +1251,13 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) u64 address; u32 addr; - devinfo->shared.scratch = dma_alloc_coherent(>pdev->dev, - BRCMF_DMA_D2H_SCRATCH_BUF_LEN, - >shared.scratch_dmahandle, GFP_KERNEL); + devinfo->shared.scratch = + dma_zalloc_coherent(>pdev->dev, + BRCMF_DMA_D2H_SCRATCH_BUF_LEN, + >shared.scratch_dmahandle, + GFP_KERNEL); if (!devinfo->shared.scratch) goto fail; - memset(devinfo->shared.scratch, 0, BRCMF_DMA_D2H_SCRATCH_BUF_LEN); - addr = devinfo->shared.tcm_base_address + BRCMF_SHARED_DMA_SCRATCH_ADDR_OFFSET; address = (u64)devinfo->shared.scratch_dmahandle; @@ -1268,14 +1267,13 @@ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) BRCMF_SHARED_DMA_SCRATCH_LEN_OFFSET; brcmf_pcie_write_tcm32(devinfo, addr, BRCMF_DMA_D2H_SCRATCH_BUF_LEN); - devinfo->shared.ringupd = dma_alloc_coherent(>pdev->dev, - BRCMF_DMA_D2H_RINGUPD_BUF_LEN, - >shared.ringupd_dmahandle, GFP_KERNEL); + devinfo->shared.ringupd = + dma_zalloc_coherent(>pdev->dev, + BRCMF_DMA_D2H_RINGUPD_BUF_LEN, + >shared.ringupd_dmahandle, + GFP_KERNEL); if (!devinfo->shared.ringupd) goto fail; - memset(devinfo->shared.ringupd, 0, BRCMF_DMA_D2H_RINGUPD_BUF_LEN); - addr = devinfo->shared.tcm_base_address + BRCMF_SHARED_DMA_RINGUPD_ADDR_OFFSET; address = (u64)devinfo->shared.ringupd_dmahandle; -- 2.7.4
Re: [PATCH v3] bcma:Adjust block comments
Hi Ashish, On Tue, Nov 28, 2017 at 09:24:58PM +0530, Ashish Kalra wrote: > use * for block comments in multiple lines according to kernel coding > style > > Reported by: checkpatch.pl > > Signed-off-by: Ashish Kalra <eashishka...@gmail.com> > --- Looks good now! FWIW, Reviewed-by: Himanshu Jha <himanshujha199...@gmail.com> > Change log: > -v3: Improvement on commit message as per review from Morgan Freeman > <morganfreeman6...@gmail.com> BTW, this <morganfreeman6...@gmail.com> is my secondary email subscibed to linux-wirless as I don't want my primary email to be flooded with frequent emails, and my upstream mail is himanshujha199...@gmail.com ! Thanks Himanshu Jha
Contributing to Linux-wireless drivers.
Hello everyone, Apologies for that forwarded email which I hurriedly sent without editing here! I am an undergraduate student in ECE(3rd year) and wish to contribute to linux-wireless drivers. I am familiar with the kernel development process and have many patches accepted in the past 2 months with variety of tools used such as coccinelle, Kasan, smatch, sparse and checkpatch. My past contributions can be found here: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/?qt=grep=Himanshu+Jha Also, James Cameron suggested me to *not self promot* and other useful stuff. But I'm not self promoting and the purpose is to avoid the initial steps that you generally recommend to a newbie like reading the conding guideline, submitting patches, learn Git etc. I have basic knowledge of Linux kernel internals and competent C skills, also planning to learn Device Drivers in future. Also, since I am beginner is there any small project that I could work on to enhance my knowledge. For eg: https://wireless.wiki.kernel.org/en/developers/gsoc/2010/wifi-test-nl80211 It is an excellent page for a beginner like me that states what should you follow and what documenation to read and other useful stuffs. Please share any links to Documentation/tutorials which I can follow and help the community. Lastly, I will next year surely apply for GSoC under Linux-wireless and I don't seem to find any participation since 2012. Could someone please explain ? Also, will Linux-wireless participate next year ? Basically, I want to be prepared beforehand so that I could contribute successfully! Thanks Eagerly awaiting your response, Himanshu Jha
Contributing to Linux-wireless drivers.
- Forwarded message from Himanshu Jha <himanshujha199...@gmail.com> - Date: Fri, 6 Oct 2017 02:05:39 +0530 From: Himanshu Jha <himanshujha199...@gmail.com> To: kv...@codeaurora.org Subject: Contributing to Linux-wireless drivers. User-Agent: Mutt/1.5.24 (2015-08-30) Hi Kalle, I am an undergraduate student in ECE(3rd year) and wish to contribute to linux-wireless drivers. I am familiar with the kernel development process and have many patches accepted in the past 2 months with variety of tools used such as coccinelle,Kasan,smatch,sparse and checkpatch. I have basic knowledge of Linux kernel internals and competent C skills, also planning to learn Device Drivers in future. The wiki page https://wireless.wiki.kernel.org/ is not working correctly, for every page it shows "This topic does not exist yet You've followed a link to a topic that doesn't exist yet. If permissions allow, you may create it by clicking on “Create this page”. Earlier I used to visit this without any issues, don't know what is the problem now ? Also, since I am beginner is there any small project that I could work on to enhance my knowledge. Please provide me any links to Documentation/tutorials which I can follow and help the community. Lastly, I will next year surely apply for GSoC under Linux-wireless and I don't seem to find any participation since 2012. Also, if there is any project that someone didn't try and is open then please let me know! I am really sorry for this direct email to you but nobody helped me on IRC channel. Thanks Himanshu Jha - End forwarded message -
[PATCH v2] mwifiex: Use put_unaligned_le32
Use put_unaligned_le32 rather than using byte ordering function and memcpy which makes code clear. Also, add the header file where it is declared. Done using Coccinelle and semantic patch used is : @ rule1 @ identifier tmp; expression ptr,x; type T; @@ - tmp = cpu_to_le32(x); <+... when != tmp - memcpy(ptr, (T), ...); + put_unaligned_le32(x,ptr); ...+> @ depends on rule1 @ type j; identifier tmp; @@ - j tmp; ...when != tmp Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- v2: * added correct header file. drivers/net/wireless/marvell/mwifiex/cmdevt.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c index 0edc5d6..e28e119 100644 --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c @@ -17,6 +17,7 @@ * this warranty disclaimer. */ +#include #include "decl.h" #include "ioctl.h" #include "util.h" @@ -183,7 +184,6 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, uint16_t cmd_code; uint16_t cmd_size; unsigned long flags; - __le32 tmp; if (!adapter || !cmd_node) return -1; @@ -249,9 +249,9 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, mwifiex_dbg_dump(adapter, CMD_D, "cmd buffer:", host_cmd, cmd_size); if (adapter->iface_type == MWIFIEX_USB) { - tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD); skb_push(cmd_node->cmd_skb, MWIFIEX_TYPE_LEN); - memcpy(cmd_node->cmd_skb->data, , MWIFIEX_TYPE_LEN); + put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, + cmd_node->cmd_skb->data); adapter->cmd_sent = true; ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_CMD_EVENT, @@ -317,7 +317,6 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) (struct mwifiex_opt_sleep_confirm *) adapter->sleep_cfm->data; struct sk_buff *sleep_cfm_tmp; - __le32 tmp; priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); @@ -342,8 +341,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) + MWIFIEX_TYPE_LEN); skb_put(sleep_cfm_tmp, sizeof(struct mwifiex_opt_sleep_confirm) + MWIFIEX_TYPE_LEN); - tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD); - memcpy(sleep_cfm_tmp->data, , MWIFIEX_TYPE_LEN); + put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, sleep_cfm_tmp->data); memcpy(sleep_cfm_tmp->data + MWIFIEX_TYPE_LEN, adapter->sleep_cfm->data, sizeof(struct mwifiex_opt_sleep_confirm)); -- 2.7.4
Re: [PATCH] mwifiex: Use put_unaligned_le32
On Thu, Oct 05, 2017 at 11:02:50AM -0700, Brian Norris wrote: > On Thu, Oct 05, 2017 at 08:52:33PM +0530, Himanshu Jha wrote: > > There are various instances where a function used in file say for eg > > int func_align (void* a) > > is used and it is defined in align.h > > But many files don't *directly* include align.h and rather include > > any other header which includes align.h > > I believe the general rule is that you should included headers for all > symbols you use, and not rely on implicit includes. > > The modification to the general rule is that not all headers are > intended to be included directly, and in such cases there's likely a > parent header that is the more appropriate target. > > In this case, the key is CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS. It > seems that asm-generic/unaligned.h is set up to include different > headers, based on the expected architecture behavior. > Yes, asm-generic/unaligned.h looks more appopriate and is most generic implementation of unaligned accesses and arc specific. Let's see what Kalle Valo recommends! And then I will send v2 of the patch. Thanks for the information! Himanshu Jha > I wonder if include/linux/unaligned/access_ok.h should have a safety > check (e.g., raise an #error if > !CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS?). > > > Is compiling the file the only way to check if apppropriate header is > > included or is there some other way to check for it. > > I believe it's mostly manual. Implicit includes have been a problem for > anyone who refactors header files. > > Brian
Re: [PATCH] mwifiex: Use put_unaligned_le32
On Thu, Oct 05, 2017 at 11:41:38AM +0300, Kalle Valo wrote: > Himanshu Jha <himanshujha199...@gmail.com> writes: > > >> > --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c > >> > +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c > >> > @@ -17,6 +17,7 @@ > >> > * this warranty disclaimer. > >> > */ > >> > > >> > +#include > >> > >> I don't think this is correct. Should it be asm/unaligned.h? > > > > Would mind explainig me as to why it is incorrect! Also, it defined in > > both the header files but, why is asm/unaligned.h preferred ? > > asm/unaligned.h seems to be the toplevel header file which includes > header files based on arch configuration. Also grepping the sources > support that, nobody from drivers/ include access_ok.h directly. > Yes, you are correct! I will send v2 patch with asm/unaligned.h > But I can't say that I fully understand how the header files work so > please do correct me if I have mistaken. > It is confusing to me as well. There are various instances where a function used in file say for eg int func_align (void* a) is used and it is defined in align.h But many files don't *directly* include align.h and rather include any other header which includes align.h Is compiling the file the only way to check if apppropriate header is included or is there some other way to check for it. Thanks
Re: [PATCH] mwifiex: Use put_unaligned_le32
On Thu, Oct 05, 2017 at 10:23:37AM +0300, Kalle Valo wrote: > Himanshu Jha <himanshujha199...@gmail.com> writes: > > > Use put_unaligned_le32 rather than using byte ordering function and > > memcpy which makes code clear. > > Also, add the header file where it is declared. > > > > Done using Coccinelle and semantic patch used is : > > > > @ rule1 @ > > identifier tmp; expression ptr,x; type T; > > @@ > > > > - tmp = cpu_to_le32(x); > > > > <+... when != tmp > > - memcpy(ptr, (T), ...); > > + put_unaligned_le32(x,ptr); > > ...+> > > > > @ depends on rule1 @ > > type j; identifier tmp; > > @@ > > > > - j tmp; > > ...when != tmp > > > > Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> > > --- > > drivers/net/wireless/marvell/mwifiex/cmdevt.c | 10 -- > > 1 file changed, 4 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c > > b/drivers/net/wireless/marvell/mwifiex/cmdevt.c > > index 0edc5d6..e28e119 100644 > > --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c > > +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c > > @@ -17,6 +17,7 @@ > > * this warranty disclaimer. > > */ > > > > +#include > > I don't think this is correct. Should it be asm/unaligned.h? Would mind explainig me as to why it is incorrect! Also, it defined in both the header files but, why is asm/unaligned.h preferred ? Thanks > -- > Kalle Valo
[PATCH] mwifiex: Use put_unaligned_le32
Use put_unaligned_le32 rather than using byte ordering function and memcpy which makes code clear. Also, add the header file where it is declared. Done using Coccinelle and semantic patch used is : @ rule1 @ identifier tmp; expression ptr,x; type T; @@ - tmp = cpu_to_le32(x); <+... when != tmp - memcpy(ptr, (T), ...); + put_unaligned_le32(x,ptr); ...+> @ depends on rule1 @ type j; identifier tmp; @@ - j tmp; ...when != tmp Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/marvell/mwifiex/cmdevt.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c index 0edc5d6..e28e119 100644 --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c @@ -17,6 +17,7 @@ * this warranty disclaimer. */ +#include #include "decl.h" #include "ioctl.h" #include "util.h" @@ -183,7 +184,6 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, uint16_t cmd_code; uint16_t cmd_size; unsigned long flags; - __le32 tmp; if (!adapter || !cmd_node) return -1; @@ -249,9 +249,9 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, mwifiex_dbg_dump(adapter, CMD_D, "cmd buffer:", host_cmd, cmd_size); if (adapter->iface_type == MWIFIEX_USB) { - tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD); skb_push(cmd_node->cmd_skb, MWIFIEX_TYPE_LEN); - memcpy(cmd_node->cmd_skb->data, , MWIFIEX_TYPE_LEN); + put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, + cmd_node->cmd_skb->data); adapter->cmd_sent = true; ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_CMD_EVENT, @@ -317,7 +317,6 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) (struct mwifiex_opt_sleep_confirm *) adapter->sleep_cfm->data; struct sk_buff *sleep_cfm_tmp; - __le32 tmp; priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); @@ -342,8 +341,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) + MWIFIEX_TYPE_LEN); skb_put(sleep_cfm_tmp, sizeof(struct mwifiex_opt_sleep_confirm) + MWIFIEX_TYPE_LEN); - tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD); - memcpy(sleep_cfm_tmp->data, , MWIFIEX_TYPE_LEN); + put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, sleep_cfm_tmp->data); memcpy(sleep_cfm_tmp->data + MWIFIEX_TYPE_LEN, adapter->sleep_cfm->data, sizeof(struct mwifiex_opt_sleep_confirm)); -- 2.7.4
[PATCH] mwifiex: remove unnecessary call to memset
call to memset to assign 0 value immediately after allocating memory with kzalloc is unnecesaary as kzalloc allocates the memory filled with 0 value. Semantic patch used to resolve this issue: @@ expression e,e2; constant c; statement S; @@ e = kzalloc(e2, c); if(e == NULL) S - memset(e, 0, e2); Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/marvell/mwifiex/scan.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/scan.c b/drivers/net/wireless/marvell/mwifiex/scan.c index c9d41ed..8838b88 100644 --- a/drivers/net/wireless/marvell/mwifiex/scan.c +++ b/drivers/net/wireless/marvell/mwifiex/scan.c @@ -1936,8 +1936,6 @@ mwifiex_active_scan_req_for_passive_chan(struct mwifiex_private *priv) if (!user_scan_cfg) return -ENOMEM; - memset(user_scan_cfg, 0, sizeof(*user_scan_cfg)); - for (id = 0; id < MWIFIEX_USER_SCAN_CHAN_MAX; id++) { if (!priv->hidden_chan[id].chan_number) break; -- 2.7.4
[PATCH v2] ath9k: remove cast to void pointer
casting to void pointer from any pointer type and vice-versa is done implicitly and therefore casting is not needed in such a case. Done using Coccinellle. Semantic Patch used : @r@ expression x; void* e; type T; identifier f; @@ ( *((T *)e) | ((T *)x)[...] | ((T *)x)->f | - (T *) e ) Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 4 ++-- drivers/net/wireless/ath/ath9k/dfs.c| 2 +- drivers/net/wireless/ath/ath9k/hif_usb.c| 8 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 24 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 6 +++--- drivers/net/wireless/ath/ath9k/init.c | 8 drivers/net/wireless/ath/ath9k/main.c | 2 +- drivers/net/wireless/ath/ath9k/mci.c| 2 +- drivers/net/wireless/ath/ath9k/wmi.c| 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index b3f20b3..e1fe7a7 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -480,7 +480,7 @@ EXPORT_SYMBOL(ath9k_hw_addrxbuf_edma); int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, void *buf_addr) { - struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr; + struct ar9003_rxs *rxsp = buf_addr; unsigned int phyerr; if ((rxsp->status11 & AR_RxDone) == 0) @@ -610,7 +610,7 @@ void ath9k_hw_setup_statusring(struct ath_hw *ah, void *ts_start, ah->ts_paddr_start = ts_paddr_start; ah->ts_paddr_end = ts_paddr_start + (size * sizeof(struct ar9003_txs)); ah->ts_size = size; - ah->ts_ring = (struct ar9003_txs *) ts_start; + ah->ts_ring = ts_start; ath9k_hw_reset_txstatus_ring(ah); } diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c index 1ece42c..40a397f 100644 --- a/drivers/net/wireless/ath/ath9k/dfs.c +++ b/drivers/net/wireless/ath/ath9k/dfs.c @@ -326,7 +326,7 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, if (ard.ext_rssi & 0x80) ard.ext_rssi = 0; - vdata_end = (char *)data + datalen; + vdata_end = data + datalen; ard.pulse_bw_info = vdata_end[-1]; ard.pulse_length_ext = vdata_end[-2]; ard.pulse_length_pri = vdata_end[-3]; diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c index 0d9687a..71d1725 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c @@ -424,7 +424,7 @@ static int hif_usb_send_tx(struct hif_device_usb *hif_dev, struct sk_buff *skb) static void hif_usb_start(void *hif_handle) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; unsigned long flags; hif_dev->flags |= HIF_USB_START; @@ -436,7 +436,7 @@ static void hif_usb_start(void *hif_handle) static void hif_usb_stop(void *hif_handle) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL; unsigned long flags; @@ -457,7 +457,7 @@ static void hif_usb_stop(void *hif_handle) static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; int ret = 0; switch (pipe_id) { @@ -492,7 +492,7 @@ static inline bool check_index(struct sk_buff *skb, u8 idx) static void hif_usb_sta_drain(void *hif_handle, u8 idx) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; struct sk_buff *skb, *tmp; unsigned long flags; diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c index 2c0e4d2..f20c839 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c @@ -384,7 +384,7 @@ void ath9k_htc_set_tsfadjust(struct ath9k_htc_priv *priv, static void ath9k_htc_beacon_iter(void *data, u8 *mac, struct ieee80211_vif *vif) { - bool *beacon_configured = (bool *)data; + bool *beacon_configured = data; struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv; if (vif->type == NL80211_IFTYPE_STATION && diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/at
[PATCH] ath9k: remove cast to void pointer
casting to void pointer from any pointer type and vice-versa is done implicitly and therefore casting is not needed in such a case. Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 4 ++-- drivers/net/wireless/ath/ath9k/dfs.c| 2 +- drivers/net/wireless/ath/ath9k/hif_usb.c| 8 drivers/net/wireless/ath/ath9k/htc_drv_beacon.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 24 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 2 +- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 6 +++--- drivers/net/wireless/ath/ath9k/init.c | 8 drivers/net/wireless/ath/ath9k/main.c | 2 +- drivers/net/wireless/ath/ath9k/mci.c| 2 +- drivers/net/wireless/ath/ath9k/wmi.c| 4 ++-- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index b3f20b3..e1fe7a7 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -480,7 +480,7 @@ EXPORT_SYMBOL(ath9k_hw_addrxbuf_edma); int ath9k_hw_process_rxdesc_edma(struct ath_hw *ah, struct ath_rx_status *rxs, void *buf_addr) { - struct ar9003_rxs *rxsp = (struct ar9003_rxs *) buf_addr; + struct ar9003_rxs *rxsp = buf_addr; unsigned int phyerr; if ((rxsp->status11 & AR_RxDone) == 0) @@ -610,7 +610,7 @@ void ath9k_hw_setup_statusring(struct ath_hw *ah, void *ts_start, ah->ts_paddr_start = ts_paddr_start; ah->ts_paddr_end = ts_paddr_start + (size * sizeof(struct ar9003_txs)); ah->ts_size = size; - ah->ts_ring = (struct ar9003_txs *) ts_start; + ah->ts_ring = ts_start; ath9k_hw_reset_txstatus_ring(ah); } diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c index 1ece42c..40a397f 100644 --- a/drivers/net/wireless/ath/ath9k/dfs.c +++ b/drivers/net/wireless/ath/ath9k/dfs.c @@ -326,7 +326,7 @@ void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, if (ard.ext_rssi & 0x80) ard.ext_rssi = 0; - vdata_end = (char *)data + datalen; + vdata_end = data + datalen; ard.pulse_bw_info = vdata_end[-1]; ard.pulse_length_ext = vdata_end[-2]; ard.pulse_length_pri = vdata_end[-3]; diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c index 0d9687a..71d1725 100644 --- a/drivers/net/wireless/ath/ath9k/hif_usb.c +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c @@ -424,7 +424,7 @@ static int hif_usb_send_tx(struct hif_device_usb *hif_dev, struct sk_buff *skb) static void hif_usb_start(void *hif_handle) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; unsigned long flags; hif_dev->flags |= HIF_USB_START; @@ -436,7 +436,7 @@ static void hif_usb_start(void *hif_handle) static void hif_usb_stop(void *hif_handle) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; struct tx_buf *tx_buf = NULL, *tx_buf_tmp = NULL; unsigned long flags; @@ -457,7 +457,7 @@ static void hif_usb_stop(void *hif_handle) static int hif_usb_send(void *hif_handle, u8 pipe_id, struct sk_buff *skb) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; int ret = 0; switch (pipe_id) { @@ -492,7 +492,7 @@ static inline bool check_index(struct sk_buff *skb, u8 idx) static void hif_usb_sta_drain(void *hif_handle, u8 idx) { - struct hif_device_usb *hif_dev = (struct hif_device_usb *)hif_handle; + struct hif_device_usb *hif_dev = hif_handle; struct sk_buff *skb, *tmp; unsigned long flags; diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c index 2c0e4d2..f20c839 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_beacon.c @@ -384,7 +384,7 @@ void ath9k_htc_set_tsfadjust(struct ath9k_htc_priv *priv, static void ath9k_htc_beacon_iter(void *data, u8 *mac, struct ieee80211_vif *vif) { - bool *beacon_configured = (bool *)data; + bool *beacon_configured = data; struct ath9k_htc_vif *avp = (struct ath9k_htc_vif *) vif->drv_priv; if (vif->type == NL80211_IFTYPE_STATION && diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index defacc6..9e0c237 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -233,7 +233,7 @@ s
[PATCH] rsi: remove memset before memcpy
calling memcpy immediately after memset with the same region of memory makes memset redundant. Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/rsi/rsi_91x_sdio.c | 1 - drivers/net/wireless/rsi/rsi_91x_usb.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c index 742f6cd..8d3a483 100644 --- a/drivers/net/wireless/rsi/rsi_91x_sdio.c +++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c @@ -584,7 +584,6 @@ static int rsi_sdio_load_data_master_write(struct rsi_hw *adapter, } for (offset = 0, i = 0; i < num_blocks; i++, offset += block_size) { - memset(temp_buf, 0, block_size); memcpy(temp_buf, ta_firmware + offset, block_size); lsb_address = (u16)base_address; status = rsi_sdio_write_register_multiple diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index 9097f7e..81df09d 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -439,7 +439,6 @@ static int rsi_usb_load_data_master_write(struct rsi_hw *adapter, rsi_dbg(INFO_ZONE, "num_blocks: %d\n", num_blocks); for (cur_indx = 0, i = 0; i < num_blocks; i++, cur_indx += block_size) { - memset(temp_buf, 0, block_size); memcpy(temp_buf, ta_firmware + cur_indx, block_size); status = rsi_usb_write_register_multiple(adapter, base_address, (u8 *)(temp_buf), -- 2.7.4
[PATCH v2] at76c50x-usb: check memory allocation failure
Check memory allocation failure and return -ENOMEM rather than just retuning void. Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/atmel/at76c50x-usb.c | 28 ++-- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/atmel/at76c50x-usb.c b/drivers/net/wireless/atmel/at76c50x-usb.c index 09defbc..ceb453b 100644 --- a/drivers/net/wireless/atmel/at76c50x-usb.c +++ b/drivers/net/wireless/atmel/at76c50x-usb.c @@ -932,7 +932,7 @@ static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff) return ret; } -static void at76_dump_mib_mac_addr(struct at76_priv *priv) +static int at76_dump_mib_mac_addr(struct at76_priv *priv) { int i; int ret; @@ -940,7 +940,7 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv) GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, sizeof(struct mib_mac_addr)); @@ -961,7 +961,7 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv) kfree(m); } -static void at76_dump_mib_mac_wep(struct at76_priv *priv) +static int at76_dump_mib_mac_wep(struct at76_priv *priv) { int i; int ret; @@ -969,7 +969,7 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv) struct mib_mac_wep *m = kmalloc(sizeof(struct mib_mac_wep), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, sizeof(struct mib_mac_wep)); @@ -999,14 +999,14 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv) kfree(m); } -static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) +static int at76_dump_mib_mac_mgmt(struct at76_priv *priv) { int ret; struct mib_mac_mgmt *m = kmalloc(sizeof(struct mib_mac_mgmt), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, sizeof(struct mib_mac_mgmt)); @@ -1037,13 +1037,13 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) kfree(m); } -static void at76_dump_mib_mac(struct at76_priv *priv) +static int at76_dump_mib_mac(struct at76_priv *priv) { int ret; struct mib_mac *m = kmalloc(sizeof(struct mib_mac), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); if (ret < 0) { @@ -1074,13 +1074,13 @@ static void at76_dump_mib_mac(struct at76_priv *priv) kfree(m); } -static void at76_dump_mib_phy(struct at76_priv *priv) +static int at76_dump_mib_phy(struct at76_priv *priv) { int ret; struct mib_phy *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); if (ret < 0) { @@ -1107,13 +1107,13 @@ static void at76_dump_mib_phy(struct at76_priv *priv) kfree(m); } -static void at76_dump_mib_local(struct at76_priv *priv) +static int at76_dump_mib_local(struct at76_priv *priv) { int ret; struct mib_local *m = kmalloc(sizeof(*m), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(*m)); if (ret < 0) { @@ -1132,13 +1132,13 @@ static void at76_dump_mib_local(struct at76_priv *priv) kfree(m); } -static void at76_dump_mib_mdomain(struct at76_priv *priv) +static int at76_dump_mib_mdomain(struct at76_priv *priv) { int ret; struct mib_mdomain *m = kmalloc(sizeof(struct mib_mdomain), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, sizeof(struct mib_mdomain)); -- 2.7.4
Re: [PATCH] drivers: net: wireless: atmel: check memory allocation failure
On Tue, Aug 22, 2017 at 10:41:45AM +0200, Matteo Croce wrote: > Il giorno mar, 22/08/2017 alle 13.41 +0530, Himanshu Jha ha scritto: > > Check memory allocation failure and return -ENOMEM if failure > > occurs. > > > > Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> > > --- > > drivers/net/wireless/atmel/at76c50x-usb.c | 14 +++--- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/net/wireless/atmel/at76c50x-usb.c > > b/drivers/net/wireless/atmel/at76c50x-usb.c > > index 09defbc..73f0924 100644 > > --- a/drivers/net/wireless/atmel/at76c50x-usb.c > > +++ b/drivers/net/wireless/atmel/at76c50x-usb.c > > @@ -940,7 +940,7 @@ static void at76_dump_mib_mac_addr(struct > > at76_priv *priv) > > GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, > >sizeof(struct mib_mac_addr)); > > @@ -969,7 +969,7 @@ static void at76_dump_mib_mac_wep(struct > > at76_priv *priv) > > struct mib_mac_wep *m = kmalloc(sizeof(struct mib_mac_wep), > > GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, > >sizeof(struct mib_mac_wep)); > > @@ -1006,7 +1006,7 @@ static void at76_dump_mib_mac_mgmt(struct > > at76_priv *priv) > > GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, > >sizeof(struct mib_mac_mgmt)); > > @@ -1043,7 +1043,7 @@ static void at76_dump_mib_mac(struct at76_priv > > *priv) > > struct mib_mac *m = kmalloc(sizeof(struct mib_mac), > > GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct > > mib_mac)); > > if (ret < 0) { > > @@ -1080,7 +1080,7 @@ static void at76_dump_mib_phy(struct at76_priv > > *priv) > > struct mib_phy *m = kmalloc(sizeof(struct mib_phy), > > GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct > > mib_phy)); > > if (ret < 0) { > > @@ -1113,7 +1113,7 @@ static void at76_dump_mib_local(struct > > at76_priv *priv) > > struct mib_local *m = kmalloc(sizeof(*m), GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(*m)); > > if (ret < 0) { > > @@ -1138,7 +1138,7 @@ static void at76_dump_mib_mdomain(struct > > at76_priv *priv) > > struct mib_mdomain *m = kmalloc(sizeof(struct mib_mdomain), > > GFP_KERNEL); > > > > if (!m) > > - return; > > + return -ENOMEM; > > > > ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, > >sizeof(struct mib_mdomain)); > > Perhaps these functions should return something instead of being void. > > Regards, > > -- > Matteo Croce > per aspera ad upstream Yes, it should return int to signal memory allocation failures and therefore function prototype should be static int rather than static void. Thanks!
[PATCH] drivers: net: wireless: atmel: check memory allocation failure
Check memory allocation failure and return -ENOMEM if failure occurs. Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com> --- drivers/net/wireless/atmel/at76c50x-usb.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/atmel/at76c50x-usb.c b/drivers/net/wireless/atmel/at76c50x-usb.c index 09defbc..73f0924 100644 --- a/drivers/net/wireless/atmel/at76c50x-usb.c +++ b/drivers/net/wireless/atmel/at76c50x-usb.c @@ -940,7 +940,7 @@ static void at76_dump_mib_mac_addr(struct at76_priv *priv) GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, sizeof(struct mib_mac_addr)); @@ -969,7 +969,7 @@ static void at76_dump_mib_mac_wep(struct at76_priv *priv) struct mib_mac_wep *m = kmalloc(sizeof(struct mib_mac_wep), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, sizeof(struct mib_mac_wep)); @@ -1006,7 +1006,7 @@ static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, sizeof(struct mib_mac_mgmt)); @@ -1043,7 +1043,7 @@ static void at76_dump_mib_mac(struct at76_priv *priv) struct mib_mac *m = kmalloc(sizeof(struct mib_mac), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); if (ret < 0) { @@ -1080,7 +1080,7 @@ static void at76_dump_mib_phy(struct at76_priv *priv) struct mib_phy *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); if (ret < 0) { @@ -1113,7 +1113,7 @@ static void at76_dump_mib_local(struct at76_priv *priv) struct mib_local *m = kmalloc(sizeof(*m), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(*m)); if (ret < 0) { @@ -1138,7 +1138,7 @@ static void at76_dump_mib_mdomain(struct at76_priv *priv) struct mib_mdomain *m = kmalloc(sizeof(struct mib_mdomain), GFP_KERNEL); if (!m) - return; + return -ENOMEM; ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, sizeof(struct mib_mdomain)); -- 2.7.4