[PATCH] staging: mt7621-dma: Fix a resource leak in an error handling path
If an error occurs after calling 'mtk_hsdma_init()', it must be undone by a corresponding call to 'mtk_hsdma_uninit()' as already done in the remove function. Fixes: 0853c7a53eb3 ("staging: mt7621-dma: ralink: add rt2880 dma engine") Signed-off-by: Christophe JAILLET --- drivers/staging/mt7621-dma/mtk-hsdma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index d241349214e7..bc4bb4374313 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -712,7 +712,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev) ret = dma_async_device_register(dd); if (ret) { dev_err(&pdev->dev, "failed to register dma device\n"); - return ret; + goto err_uninit_hsdma; } ret = of_dma_controller_register(pdev->dev.of_node, @@ -728,6 +728,8 @@ static int mtk_hsdma_probe(struct platform_device *pdev) err_unregister: dma_async_device_unregister(dd); +err_uninit_hsdma: + mtk_hsdma_uninit(hsdma); return ret; } -- 2.27.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: spmi: hisi-spmi-controller: Fix some error handling paths
IN the probe function, if an error occurs after calling 'spmi_controller_alloc()', it must be undone by a corresponding 'spmi_controller_put() call. In the remove function, use 'spmi_controller_put(ctrl)' instead of 'kfree(ctrl)'. While a it fix an error message (s/spmi_add_controller/spmi_controller_add/) Signed-off-by: Christophe JAILLET --- .../staging/hikey9xx/hisi-spmi-controller.c | 21 +-- 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/staging/hikey9xx/hisi-spmi-controller.c b/drivers/staging/hikey9xx/hisi-spmi-controller.c index 861aedd5de48..0d42bc65f39b 100644 --- a/drivers/staging/hikey9xx/hisi-spmi-controller.c +++ b/drivers/staging/hikey9xx/hisi-spmi-controller.c @@ -278,21 +278,24 @@ static int spmi_controller_probe(struct platform_device *pdev) iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!iores) { dev_err(&pdev->dev, "can not get resource!\n"); - return -EINVAL; + ret = -EINVAL; + goto err_put_controller; } spmi_controller->base = devm_ioremap(&pdev->dev, iores->start, resource_size(iores)); if (!spmi_controller->base) { dev_err(&pdev->dev, "can not remap base addr!\n"); - return -EADDRNOTAVAIL; + ret = -EADDRNOTAVAIL; + goto err_put_controller; } ret = of_property_read_u32(pdev->dev.of_node, "spmi-channel", &spmi_controller->channel); if (ret) { dev_err(&pdev->dev, "can not get channel\n"); - return -ENODEV; + ret = -ENODEV; + goto err_put_controller; } platform_set_drvdata(pdev, spmi_controller); @@ -309,9 +312,15 @@ static int spmi_controller_probe(struct platform_device *pdev) ctrl->write_cmd = spmi_write_cmd; ret = spmi_controller_add(ctrl); - if (ret) - dev_err(&pdev->dev, "spmi_add_controller failed with error %d!\n", ret); + if (ret) { + dev_err(&pdev->dev, "spmi_controller_add failed with error %d!\n", ret); + goto err_put_controller; + } + + return 0; +err_put_controller: + spmi_controller_put(ctrl); return ret; } @@ -320,7 +329,7 @@ static int spmi_del_controller(struct platform_device *pdev) struct spmi_controller *ctrl = platform_get_drvdata(pdev); spmi_controller_remove(ctrl); - kfree(ctrl); + spmi_controller_put(ctrl); return 0; } -- 2.27.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] vme: switch from 'pci_' to 'dma_' API
The wrappers in include/linux/pci-dma-compat.h should go away. The patch has been generated with the coccinelle script below and has been hand modified to replace GFP_ with a correct flag. It has been compile tested. When memory is allocated in 'ca91cx42_alloc_consistent()' and 'tsi148_alloc_consistent()' GFP_KERNEL can be used because both functions are called only from 'vme_alloc_consistent()' (vme.c). This function is only called from the 'vme_user_probe()' probe function and no lock is taken in the between. When memory is allocated in 'ca91cx42_crcsr_init()' and 'tsi148_crcsr_init()' GFP_KERNEL can be used because both functions are called only from their corresponding probe function and no lock is taken in the between. @@ @@ -PCI_DMA_BIDIRECTIONAL +DMA_BIDIRECTIONAL @@ @@ -PCI_DMA_TODEVICE +DMA_TO_DEVICE @@ @@ -PCI_DMA_FROMDEVICE +DMA_FROM_DEVICE @@ @@ -PCI_DMA_NONE +DMA_NONE @@ expression e1, e2, e3; @@ -pci_alloc_consistent(e1, e2, e3) +dma_alloc_coherent(&e1->dev, e2, e3, GFP_) @@ expression e1, e2, e3; @@ -pci_zalloc_consistent(e1, e2, e3) +dma_alloc_coherent(&e1->dev, e2, e3, GFP_) @@ expression e1, e2, e3, e4; @@ -pci_free_consistent(e1, e2, e3, e4) +dma_free_coherent(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_map_single(e1, e2, e3, e4) +dma_map_single(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_unmap_single(e1, e2, e3, e4) +dma_unmap_single(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4, e5; @@ -pci_map_page(e1, e2, e3, e4, e5) +dma_map_page(&e1->dev, e2, e3, e4, e5) @@ expression e1, e2, e3, e4; @@ -pci_unmap_page(e1, e2, e3, e4) +dma_unmap_page(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_map_sg(e1, e2, e3, e4) +dma_map_sg(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_unmap_sg(e1, e2, e3, e4) +dma_unmap_sg(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_dma_sync_single_for_cpu(e1, e2, e3, e4) +dma_sync_single_for_cpu(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_dma_sync_single_for_device(e1, e2, e3, e4) +dma_sync_single_for_device(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_dma_sync_sg_for_cpu(e1, e2, e3, e4) +dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4) @@ expression e1, e2, e3, e4; @@ -pci_dma_sync_sg_for_device(e1, e2, e3, e4) +dma_sync_sg_for_device(&e1->dev, e2, e3, e4) @@ expression e1, e2; @@ -pci_dma_mapping_error(e1, e2) +dma_mapping_error(&e1->dev, e2) @@ expression e1, e2; @@ -pci_set_dma_mask(e1, e2) +dma_set_mask(&e1->dev, e2) @@ expression e1, e2; @@ -pci_set_consistent_dma_mask(e1, e2) +dma_set_coherent_mask(&e1->dev, e2) Signed-off-by: Christophe JAILLET --- If needed, see post from Christoph Hellwig on the kernel-janitors ML: https://marc.info/?l=kernel-janitors&m=158745678307186&w=4 --- drivers/vme/bridges/vme_ca91cx42.c | 13 +++-- drivers/vme/bridges/vme_tsi148.c | 13 +++-- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/vme/bridges/vme_ca91cx42.c b/drivers/vme/bridges/vme_ca91cx42.c index ea938dc29c5e..439b0edeca08 100644 --- a/drivers/vme/bridges/vme_ca91cx42.c +++ b/drivers/vme/bridges/vme_ca91cx42.c @@ -1510,7 +1510,7 @@ static void *ca91cx42_alloc_consistent(struct device *parent, size_t size, /* Find pci_dev container of dev */ pdev = to_pci_dev(parent); - return pci_alloc_consistent(pdev, size, dma); + return dma_alloc_coherent(&pdev->dev, size, dma, GFP_KERNEL); } static void ca91cx42_free_consistent(struct device *parent, size_t size, @@ -1521,7 +1521,7 @@ static void ca91cx42_free_consistent(struct device *parent, size_t size, /* Find pci_dev container of dev */ pdev = to_pci_dev(parent); - pci_free_consistent(pdev, size, vaddr, dma); + dma_free_coherent(&pdev->dev, size, vaddr, dma); } /* @@ -1555,8 +1555,9 @@ static int ca91cx42_crcsr_init(struct vme_bridge *ca91cx42_bridge, } /* Allocate mem for CR/CSR image */ - bridge->crcsr_kernel = pci_zalloc_consistent(pdev, VME_CRCSR_BUF_SIZE, -&bridge->crcsr_bus); + bridge->crcsr_kernel = dma_alloc_coherent(&pdev->dev, + VME_CRCSR_BUF_SIZE, + &bridge->crcsr_bus, GFP_KERNEL); if (!bridge->crcsr_kernel) { dev_err(&pdev->dev, "Failed to allocate memory for CR/CSR " "image\n"); @@ -1589,8 +1590,8 @@ static void ca91cx42_crcsr_exit(struct
Re: [PATCH] staging: wfx: make a const array static, makes object smaller
Le 17/10/2020 à 02:11, Joe Perches a écrit : On Fri, 2020-10-16 at 23:33 +0100, Colin King wrote: From: Colin Ian King Don't populate const array filter_ies on the stack but instead make it static. Makes the object code smaller by 261 bytes. Before: text data bss dec hex filename 21674 3166 448 2528862c8 drivers/staging/wfx/sta.o After: text data bss dec hex filename 21349 3230 448 2502761c3 drivers/staging/wfx/sta.o Thanks. It's odd to me it's so large a change as it's only 24 bytes of initialization. (3 entries, each 8 bytes) The function looks small. Maybe it is inlined by gcc in each of the 3 callers? CJ This line in the same function: hif_set_beacon_filter_table(wvif, 3, filter_ies); might as well use ARRAY_SIZE(filter_ies) instead of 3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] media: staging/intel-ipu3: css: Correctly reset some memory
The intent here is to reset the whole 'scaler_coeffs_luma' array, not just the first element. Fixes: e0a5b744 ("media: staging/intel-ipu3: css: Compute and program ccs") Signed-off-by: Christophe JAILLET --- drivers/staging/media/ipu3/ipu3-css-params.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/ipu3/ipu3-css-params.c b/drivers/staging/media/ipu3/ipu3-css-params.c index fbd53d7c097c..e9d6bd9e9332 100644 --- a/drivers/staging/media/ipu3/ipu3-css-params.c +++ b/drivers/staging/media/ipu3/ipu3-css-params.c @@ -159,7 +159,7 @@ imgu_css_scaler_calc(u32 input_width, u32 input_height, u32 target_width, memset(&cfg->scaler_coeffs_chroma, 0, sizeof(cfg->scaler_coeffs_chroma)); - memset(&cfg->scaler_coeffs_luma, 0, sizeof(*cfg->scaler_coeffs_luma)); + memset(&cfg->scaler_coeffs_luma, 0, sizeof(cfg->scaler_coeffs_luma)); do { phase_step_correction++; -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192u: Do not use GFP_KERNEL in atomic context
'rtl8192_irq_rx_tasklet()' is a tasklet initialized in 'rtl8192_init_priv_task()'. >From this function it is possible to allocate some memory with the GFP_KERNEL flag, which is not allowed in the atomic context of a tasklet. Use GFP_ATOMIC instead. The call chain is: rtl8192_irq_rx_tasklet(in r8192U_core.c) --> rtl8192_rx_nomal(in r8192U_core.c) --> ieee80211_rx (in ieee80211/ieee80211_rx.c) --> RxReorderIndicatePacket (in ieee80211/ieee80211_rx.c) Fixes: 79a5ccd97209 ("staging: rtl8192u: fix large frame size compiler warning") Signed-off-by: Christophe JAILLET --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 195d963c4fbb..b6fee7230ce0 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -597,7 +597,7 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, prxbIndicateArray = kmalloc_array(REORDER_WIN_SIZE, sizeof(struct ieee80211_rxb *), - GFP_KERNEL); + GFP_ATOMIC); if (!prxbIndicateArray) return; -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: ks7010: Do not use GFP_KERNEL in atomic context
A possible call chain is as follow: ks_wlan_start_xmit(ks_wlan_net.c) --> hostif_data_request (ks_hostif.c) --> michael_mic (ks_hostif.c) 'ks_wlan_start_xmit()' is a '.ndo_start_xmit()' function (see net_device_ops structure). Such calls are guarded by the __netif_tx_lock spinlock. So memory allocation must be atomic. So, use GFP_ATOMIC instead of GFP_KERNEL 'in michael_mic()' Fixes: ??? Signed-off-by: Christophe JAILLET --- This is completely speculative. I don't know if the call chain given above if possible in RL application. So review carefully :) If the fix is correct, it is also more the starting point of a bigger change, because in 'michael_mic()' there is a call to 'crypto_alloc_shash()' and this function uses GFP_KERNEL internally (in 'crypto_create_tfm()') Should this need to be changed, I don't know how 'ks_hostif.c' should be fixed. Changing allocation in 'crypto/api.c' looks like an overkill. In other word, I think that my patch is wrong, but don't know what else to propose :). --- drivers/staging/ks7010/ks_hostif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index d70b671b06aa..c66f50e4a158 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -212,7 +212,7 @@ michael_mic(u8 *key, u8 *data, unsigned int len, u8 priority, u8 *result) if (ret < 0) goto err_free_tfm; - desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_KERNEL); + desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_ATOMIC); if (!desc) { ret = -ENOMEM; goto err_free_tfm; -- 2.25.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: comedi: s626: Remove pci-dma-compat wrapper APIs.
Le 11/07/2020 à 14:35, Suraj Upadhyay a écrit : The legacy API wrappers in include/linux/pci-dma-compat.h should go away as it creates unnecessary midlayering for include/linux/dma-mapping.h APIs, instead use dma-mapping.h APIs directly. The patch has been generated with the coccinelle script below and compile-tested. [...] @@ expression E1, E2, E3; @@ - pci_alloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) @@ expression E1, E2, E3; @@ - pci_zalloc_consistent(E1, E2, E3) + dma_alloc_coherent(&E1->dev, E2, E3, GFP_ATOMIC) This is the tricky part of this kind of cleanup, see below. GFP_ATOMIC can't be wrong because it is was exactly what was done with the pci_ function. However, most of the time, it can safely be replaced by GFP_KERNEL which gives more opportunities to the memory allocator. [...] diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 084a8e7b9fc2..c159416662fd 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2130,13 +2130,15 @@ static int s626_allocate_dma_buffers(struct comedi_device *dev) void *addr; dma_addr_t appdma; - addr = pci_alloc_consistent(pcidev, S626_DMABUF_SIZE, &appdma); + addr = dma_alloc_coherent(&pcidev->dev, S626_DMABUF_SIZE, &appdma, + GFP_ATOMIC); if (!addr) return -ENOMEM; devpriv->ana_buf.logical_base = addr; devpriv->ana_buf.physical_base = appdma; - addr = pci_alloc_consistent(pcidev, S626_DMABUF_SIZE, &appdma); + addr = dma_alloc_coherent(&pcidev->dev, S626_DMABUF_SIZE, &appdma, + GFP_ATOMIC); if (!addr) return -ENOMEM; devpriv->rps_buf.logical_base = addr; 's626_allocate_dma_buffers()' is only called from 's626_auto_attach()'. In this function, around the call to 's626_allocate_dma_buffers()', you can see: - a few lines before, a call to 'comedi_alloc_devpriv()' - a few lines after, a call to 'comedi_alloc_subdevices()' These 2 functions make some memory allocation using GFP_KERNEL. So it is likely that using GFP_KERNEL in your proposal is also valid. Just my 2c. CJ ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: wfx: Fix a memory leak in 'wfx_upload_beacon'
The current code is a no-op, because all it can do is 'dev_kfree_skb(NULL)' Remove the test before 'dev_kfree_skb()' Signed-off-by: Christophe JAILLET --- V2: remove the 'if(...)', 'dev_kfree_skb()' can handle NULL. --- drivers/staging/wfx/sta.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 688586e823c0..93f3739b5f3a 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -906,8 +906,7 @@ static int wfx_upload_beacon(struct wfx_vif *wvif) wfx_fwd_probe_req(wvif, false); done: - if (!skb) - dev_kfree_skb(skb); + dev_kfree_skb(skb); return ret; } -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: wfx: Fix a memory leak in 'wfx_upload_beacon'
The current code is a no-op, because all it can do is 'dev_kfree_skb(NULL)' Revert the test to free skb, if not NULL. Signed-off-by: Christophe JAILLET --- This patch is purely speculative. The 'if (...)' could also be removed completely if we refactor the code and return directly at the beginning of the function. Or the 'return -ENOMEM' should be 'err = -ENOMEM; goto done;' in order to avoid a mixup of goto and direct return. --- drivers/staging/wfx/sta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 688586e823c0..e14da8dce388 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -906,7 +906,7 @@ static int wfx_upload_beacon(struct wfx_vif *wvif) wfx_fwd_probe_req(wvif, false); done: - if (!skb) + if (skb) dev_kfree_skb(skb); return ret; } -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8712: Improve naming of include hearder guards
Choose a better name for the include hearder guard used in rtl871x_io.h. '_IO_H_' is to generic and does not match the comment after the #endif. Use '_RTL871X_IO_H_' instead. Also make the comments in the #endif /* XXX */ match the name used in #ifndef. Signed-off-by: Christophe JAILLET --- __RTL871X_RF_H_ could have been turned into _RTL871X_RF_H_ (one leading '_' removed) but there does not seem to be a clear logic in the way the header guards are named in this directory. So leave it as-is in order to limit the diff. --- drivers/staging/rtl8712/rtl871x_io.h | 7 +++ drivers/staging/rtl8712/rtl871x_rf.h | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h index 28941423b7ed..c20dd5a6bbd1 100644 --- a/drivers/staging/rtl8712/rtl871x_io.h +++ b/drivers/staging/rtl8712/rtl871x_io.h @@ -11,8 +11,8 @@ * Larry Finger * **/ -#ifndef _IO_H_ -#define _IO_H_ +#ifndef _RTL871X_IO_H_ +#define _RTL871X_IO_H_ #include "osdep_service.h" #include "osdep_intf.h" @@ -234,5 +234,4 @@ void r8712_write_port(struct _adapter *adapter, u32 addr, u32 cnt, u8 *pmem); uint r8712_alloc_io_queue(struct _adapter *adapter); void r8712_free_io_queue(struct _adapter *adapter); -#endif /*_RTL8711_IO_H_*/ - +#endif /*_RTL871X_IO_H_*/ diff --git a/drivers/staging/rtl8712/rtl871x_rf.h b/drivers/staging/rtl8712/rtl871x_rf.h index cc54453cd424..7d98921a48fa 100644 --- a/drivers/staging/rtl8712/rtl871x_rf.h +++ b/drivers/staging/rtl8712/rtl871x_rf.h @@ -52,5 +52,4 @@ enum { RTL8712_RFC_2T2R = 0x22 }; -#endif /*_RTL8711_RF_H_*/ - +#endif /*__RTL871X_RF_H_*/ -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: fbtft: Fix some typo. pdc8544 --> pcd8544
The driver is related to 'pcd8544'. However, 2 strings are about pdc8544 (c and d switched) Fix it. Signed-off-by: Christophe JAILLET --- This patch is only theorical. It is based on the fact that a part of the filename (i.e. pcd8544) looks misspelled in the file itself. I don't know the implication of FBTFT_REGISTER_DRIVER and MODULE_ALIAS and if additional adjustments are needed. --- drivers/staging/fbtft/fb_pcd8544.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fb_pcd8544.c b/drivers/staging/fbtft/fb_pcd8544.c index ad49973ad594..08f8a4bb8772 100644 --- a/drivers/staging/fbtft/fb_pcd8544.c +++ b/drivers/staging/fbtft/fb_pcd8544.c @@ -157,10 +157,10 @@ static struct fbtft_display display = { .backlight = 1, }; -FBTFT_REGISTER_DRIVER(DRVNAME, "philips,pdc8544", &display); +FBTFT_REGISTER_DRIVER(DRVNAME, "philips,pcd8544", &display); MODULE_ALIAS("spi:" DRVNAME); -MODULE_ALIAS("spi:pdc8544"); +MODULE_ALIAS("spi:pcd8544"); MODULE_DESCRIPTION("FB driver for the PCD8544 LCD Controller"); MODULE_AUTHOR("Noralf Tronnes"); -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: unisys: visornic: Update the description of 'poll_for_irq()'
Commit e99e88a9d2b06 ("treewide: setup_timer() -> timer_setup()") has updated the parameters of 'poll_for_irq()' but not the comment above the function. Update the comment and fix a typo. s/visronic/visornic/ Signed-off-by: Christophe JAILLET --- drivers/staging/unisys/visornic/visornic_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index 9d4f1dab0968..40dd573e73c3 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -1750,7 +1750,8 @@ static int visornic_poll(struct napi_struct *napi, int budget) } /* poll_for_irq- checks the status of the response queue - * @v: Void pointer to the visronic devdata struct. + * @t: pointer to the 'struct timer_list' from which we can retrieve the + * the visornic devdata struct. * * Main function of the vnic_incoming thread. Periodically check the response * queue and drain it if needed. -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: bcm2835-camera: Avoid apotential sleep while holding a spin_lock
Do not allocate memory with GFP_KERNEL when holding a spin_lock, it may sleep. Use GFP_NOWAIT instead. Fixes: 950fd867c635 ("staging: bcm2835-camera: Replace open-coded idr with a struct idr.") Signed-off-by: Christophe JAILLET --- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 16af735af5c3..438d548c6e24 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -186,7 +186,7 @@ get_msg_context(struct vchiq_mmal_instance *instance) */ spin_lock(&instance->context_map_lock); handle = idr_alloc(&instance->context_map, msg_context, - 0, 0, GFP_KERNEL); + 0, 0, GFP_NOWAIT); spin_unlock(&instance->context_map_lock); if (handle < 0) { -- 2.20.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8723bs: Fix the return value in case of error in 'rtw_wx_read32()'
We return 0 unconditionally in 'rtw_wx_read32()'. However, 'ret' is set to some error codes in several error handling paths. Return 'ret' instead to propagate the error code. Fixes: 554c0a3abf216 ("staging: Add rtl8723bs sdio wifi driver") Signed-off-by: Christophe JAILLET --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 28bfdbdc6e76..b8631baf128d 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2289,7 +2289,7 @@ static int rtw_wx_read32(struct net_device *dev, exit: kfree(ptmp); - return 0; + return ret; } static int rtw_wx_write32(struct net_device *dev, -- 2.17.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: lustre: Use 'kvfree()' for memory allocated by 'kvzalloc()'
'buf' is allocated with 'kvzalloc()'. 'kvfree()' must be used to free it. Signed-off-by: Christophe JAILLET --- drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 693e1129f1f9..5e04d133b596 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -385,7 +385,7 @@ static int llog_process_thread(void *arg) if (cd) cd->lpcd_last_idx = last_called_index; - kfree(buf); + kvfree(buf); lpi->lpi_rc = rc; return 0; } -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: lustre: Fix an error handling path in 'client_common_fill_super()'
According to error handling path before and after this one, we should go to 'out_md_fid' here, instead of 'out_md', if 'obd_connect()' fails. Signed-off-by: Christophe JAILLET --- The last goto 'out_lock_cn_cb' looks spurious but is correct. In case of error, 'd_make_root()' performs a 'iput()', so skipping it in the error handling path lokks fine to me. --- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 60dbe888e336..83eb2da2c9ad 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -400,11 +400,11 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt) LCONSOLE_ERROR_MSG(0x150, "An OST (dt %s) is performing recovery, of which this client is not a part. Please wait for recovery to complete, abort, or time out.\n", dt); - goto out_md; + goto out_md_fid; } else if (err) { CERROR("%s: Cannot connect to %s: rc = %d\n", sbi->ll_dt_exp->exp_obd->obd_name, dt, err); - goto out_md; + goto out_md_fid; } sbi->ll_dt_exp->exp_connect_data = *data; -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/3] media: staging: atomisp: Return an error code in case of error in 'lm3554_probe()'
If 'v4l2_ctrl_handler_init()' fails, we go to the error handling path, do some clean-up and return err, which is known to be 0 (i.e. success). Axe the 'ret' variable and use 'err' directly in order to return the error code instead. Also remove the initialization of 'err' which was hiding this issue. Signed-off-by: Christophe JAILLET --- drivers/staging/media/atomisp/i2c/atomisp-lm3554.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c index 7098bf317f16..723fa74ff815 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c @@ -852,10 +852,9 @@ static void *lm3554_platform_data_func(struct i2c_client *client) static int lm3554_probe(struct i2c_client *client) { - int err = 0; + int err; struct lm3554 *flash; unsigned int i; - int ret; flash = kzalloc(sizeof(*flash), GFP_KERNEL); if (!flash) @@ -868,10 +867,9 @@ static int lm3554_probe(struct i2c_client *client) flash->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; flash->mode = ATOMISP_FLASH_MODE_OFF; flash->timeout = LM3554_MAX_TIMEOUT / LM3554_TIMEOUT_STEPSIZE - 1; - ret = - v4l2_ctrl_handler_init(&flash->ctrl_handler, - ARRAY_SIZE(lm3554_controls)); - if (ret) { + err = v4l2_ctrl_handler_init(&flash->ctrl_handler, +ARRAY_SIZE(lm3554_controls)); + if (err) { dev_err(&client->dev, "error initialize a ctrl_handler.\n"); goto fail2; } -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/3] media: staging: atomisp: Fix an error handling path in 'lm3554_probe()'
The use of 'fail1' and 'fail2' is not correct. Reorder these calls to branch at the right place of the error handling path. Signed-off-by: Christophe JAILLET --- drivers/staging/media/atomisp/i2c/atomisp-lm3554.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c index 723fa74ff815..1e5f516f6e50 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c @@ -871,7 +871,7 @@ static int lm3554_probe(struct i2c_client *client) ARRAY_SIZE(lm3554_controls)); if (err) { dev_err(&client->dev, "error initialize a ctrl_handler.\n"); - goto fail2; + goto fail1; } for (i = 0; i < ARRAY_SIZE(lm3554_controls); i++) @@ -879,7 +879,6 @@ static int lm3554_probe(struct i2c_client *client) NULL); if (flash->ctrl_handler.error) { - dev_err(&client->dev, "ctrl_handler error.\n"); goto fail2; } @@ -888,7 +887,7 @@ static int lm3554_probe(struct i2c_client *client) err = media_entity_pads_init(&flash->sd.entity, 0, NULL); if (err) { dev_err(&client->dev, "error initialize a media entity.\n"); - goto fail1; + goto fail2; } flash->sd.entity.function = MEDIA_ENT_F_FLASH; -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 3/3] media: staging: atomisp: Fix usage of 'media_entity_cleanup()'
According to the doc, 'media_entity_cleanup()' must be called after unregistering the entity. All places I've check do it that way. So, move the call after 'v4l2_device_unregister_subdev()' as done elsewhere. Actually, this is not an issue, because 'media_entity_cleanup()' does nothing, but it is more future proof. Signed-off-by: Christophe JAILLET --- The change from '&flash->sd.entity' to '&sd->entity' in the last hunk is done because most of the drivers I've checked do it that way. Not sure if it is correct. It looks logical to me and it can be compiled. That's all I know. If this patch is reviewed and confirmed, I'll propose similar fixes for some other drivers. --- drivers/staging/media/atomisp/i2c/atomisp-lm3554.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c index 1e5f516f6e50..b369b101abe7 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c @@ -902,11 +902,12 @@ static int lm3554_probe(struct i2c_client *client) goto fail2; } return atomisp_register_i2c_module(&flash->sd, NULL, LED_FLASH); + fail2: - media_entity_cleanup(&flash->sd.entity); v4l2_ctrl_handler_free(&flash->ctrl_handler); fail1: v4l2_device_unregister_subdev(&flash->sd); + media_entity_cleanup(&flash->sd.entity); kfree(flash); return err; @@ -918,9 +919,9 @@ static int lm3554_remove(struct i2c_client *client) struct lm3554 *flash = to_lm3554(sd); int ret; - media_entity_cleanup(&flash->sd.entity); v4l2_ctrl_handler_free(&flash->ctrl_handler); v4l2_device_unregister_subdev(sd); + media_entity_cleanup(&sd->entity); atomisp_gmin_remove_subdev(sd); -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 0/3] media: staging: atomisp:
These 3 patches fixes (at least I hope) some issues found in or around 'lm3554_probe()'. Please review them carefully. I've only compile tested the changes and I propose them because they sound logical to me. The first one, return an error code instead of 0 if the call to an initialisation function fails. The 2nd one reorders own some label are reached in order to have a logical flow (first error goes to last label, last error goes to first label) The 3rd one fix the use 'media_entity_cleanup()'. If this one is correct, some other drivers will need to be fixed the same way. Christophe JAILLET (3): media: staging: atomisp: Return an error code in case of error in 'lm3554_probe()' media: staging: atomisp: Fix an error handling path in 'lm3554_probe()' media: staging: atomisp: Fix usage of 'media_entity_cleanup()' .../media/atomisp/i2c/atomisp-lm3554.c| 20 +-- 1 file changed, 9 insertions(+), 11 deletions(-) -- 2.17.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Re: [PATCH] staging: wilc1000: replace kmalloc + memcpy with kmemdup
Le 26/03/2018 à 19:16, Colin King a écrit : From: Colin Ian King Replace several allocation and memcpys with kmemdup and add in some missing memory allocation failure checks. Also fix an incorrect -EFAULT return with -ENOMEM. Signed-off-by: Colin Ian King --- drivers/staging/wilc1000/host_interface.c | 75 +++ 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9b9b86654958..8fd367f87fa5 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c [...] hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len; if (conn_attr->ssid) { - hif_drv->usr_conn_req.ssid = kmalloc(conn_attr->ssid_len + 1, + hif_drv->usr_conn_req.ssid = kmemdup(conn_attr->ssid, +conn_attr->ssid_len + 1, GFP_KERNEL); if (!hif_drv->usr_conn_req.ssid) { result = -ENOMEM; goto error; } - memcpy(hif_drv->usr_conn_req.ssid, - conn_attr->ssid, - conn_attr->ssid_len); > hif_drv->usr_conn_req.ssid[conn_attr->ssid_len] = '\0'; I don't know if it is an issue, but now the memcpy is 1 more byte (conn_attr->ssid_len vs conn_attr->ssid_len + 1) kmemdup_nul(conn_attr->ssid, conn_attr->ssid_len, GFP_KERNEL) and remove hif_drv->usr_conn_req.ssid[conn_attr->ssid_len] = '\0' ? CJ [...] ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: vme: vme_user: Fix some error handling paths in 'vme_user_probe()'
2 gotos in error handling paths branch to the wrong label. Fix it. Signed-off-by: Christophe JAILLET --- drivers/staging/vme/devices/vme_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 3242dee8246f..6a33aaa1a49f 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -558,7 +558,7 @@ static int vme_user_probe(struct vme_dev *vdev) vme_user_cdev->owner = THIS_MODULE; err = cdev_add(vme_user_cdev, MKDEV(VME_MAJOR, 0), VME_DEVS); if (err) - goto err_char; + goto err_class; /* Request slave resources and allocate buffers (128kB wide) */ for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) { @@ -618,7 +618,7 @@ static int vme_user_probe(struct vme_dev *vdev) if (IS_ERR(vme_user_sysfs_class)) { dev_err(&vdev->dev, "Error creating vme_user class.\n"); err = PTR_ERR(vme_user_sysfs_class); - goto err_class; + goto err_master; } /* Add sysfs Entries */ -- 2.14.1 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192u: Fix some error handling path
If 'rtl8192_usb_initendpoints()' fails, it may have allocated some resources that need to be freed. The corresponding is propagated up to 'rtl8192_usb_prob()'. So, in this function if an error code is returned by 'rtl8192_init()' we should call 'rtl8192_usb_deleteendpoints()'. Some error handling code is also duplicated in 'rtl8192_init()' and in 'rtl8192_usb_prob()'. This looks harmless because the freed pointers are set to NULL but it looks confusing. Fix all that by just moving the 'fail' label and removing duplicated error handling code from 'rtl8192_ini()'. All this resources freeing will be handled by 'rtl8192_usb_prob()' directly. The calling graph is: rtl8192_usb_probe --> rtl8192_init --> rtl8192_usb_initendpoints Signed-off-by: Christophe JAILLET --- This patch is compile tested and the corresponding looks a bit tricky. So, review carefully :) --- drivers/staging/rtl8192u/r8192U_core.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 48b7fd071900..8701ce25abe4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -2694,9 +2694,6 @@ static short rtl8192_init(struct net_device *dev) err = rtl8192_read_eeprom_info(dev); if (err) { DMESG("Reading EEPROM info failed"); - kfree(priv->pFirmware); - priv->pFirmware = NULL; - free_ieee80211(dev); return err; } rtl8192_get_channel_map(dev); @@ -4998,11 +4995,11 @@ static int rtl8192_usb_probe(struct usb_interface *intf, fail2: rtl8192_down(dev); +fail: kfree(priv->pFirmware); priv->pFirmware = NULL; rtl8192_usb_deleteendpoints(dev); mdelay(10); -fail: free_ieee80211(dev); RT_TRACE(COMP_ERR, "wlan driver load failed\n"); -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: rtl8192u: Check some memory allocation failure
If one of these memory allocations fail, a NULL pointer dereference will occur later on. Return -ENOMEM instead. There is no need to free the resources already allocated, this is done by the caller (i.e. 'rtl8192_usb_probe()') which calls 'rtl8192_usb_deleteendpoints()'. The calling graph is: rtl8192_usb_probe --> rtl8192_init --> rtl8192_usb_initendpoints Signed-off-by: Christophe JAILLET --- The error handling path in 'rtl8192_usb_probe' must also be fixed because it is bogus. Will do that in another patch. --- drivers/staging/rtl8192u/r8192U_core.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 46b3f19e0878..48b7fd071900 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1687,9 +1687,13 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) #ifndef JACKSON_NEW_RX for (i = 0; i < (MAX_RX_URB + 1); i++) { priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); + if (!priv->rx_urb[i]) + return -ENOMEM; priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); + if (!priv->rx_urb[i]->transfer_buffer) + return -ENOMEM; priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] Staging: media: Release the correct resource in an error handling path
'res' is reassigned several times in the function and if we 'goto error_unmap', its value is not the returned value of 'request_mem_region()' anymore. Introduce a new 'struct resource *' variable (i.e. res2) to keep a pointer to the right resource, if needed in the error handling path. Fixes: 4b4eda001704 ("Staging: media: Unmap and release region obtained by ioremap_nocache") Signed-off-by: Christophe JAILLET --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 6a3434cebd79..8d2d3f8edc07 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1791,7 +1791,7 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) struct v4l2_subdev *sd = &ipipe->subdev; struct media_entity *me = &sd->entity; static resource_size_t res_len; - struct resource *res; + struct resource *res, *res2; res = platform_get_resource(pdev, IORESOURCE_MEM, 4); if (!res) @@ -1805,10 +1805,10 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) if (!ipipe->base_addr) goto error_release; - res = platform_get_resource(pdev, IORESOURCE_MEM, 6); - if (!res) + res2 = platform_get_resource(pdev, IORESOURCE_MEM, 6); + if (!res2) goto error_unmap; - ipipe->isp5_base_addr = ioremap_nocache(res->start, res_len); + ipipe->isp5_base_addr = ioremap_nocache(res2->start, res_len); if (!ipipe->isp5_base_addr) goto error_unmap; -- 2.11.0 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH v2] staging: bcm2835-camera: Fix a memory leak in error handling path in 'bm2835_mmal_init()'
If 'kzalloc()' fails, we should release resources allocated so far, just as done in all other cases in this function. Signed-off-by: Christophe JAILLET --- Not sure that the error handling path is correct. Is 'gdev[0]' freed? Should it be? v2: Rename patch to include '-camera' in the subject --- drivers/staging/media/platform/bcm2835/bcm2835-camera.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c index ca15a698e018..9651b9bc3439 100644 --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c @@ -1914,8 +1914,10 @@ static int __init bm2835_mmal_init(void) for (camera = 0; camera < num_cameras; camera++) { dev = kzalloc(sizeof(struct bm2835_mmal_dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; + if (!dev) { + ret = -ENOMEM; + goto free_dev; + } dev->camera_num = camera; dev->max_width = resolutions[camera][0]; -- 2.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: bcm2835: Fix a memory leak in error handling path
If 'kzalloc()' fails, we should release resources allocated so far, just as done in all other cases in this function. Signed-off-by: Christophe JAILLET --- Not sure that the error handling path is correct. Is 'gdev[0]' freed? Should it be? --- drivers/staging/media/platform/bcm2835/bcm2835-camera.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c index ca15a698e018..9651b9bc3439 100644 --- a/drivers/staging/media/platform/bcm2835/bcm2835-camera.c +++ b/drivers/staging/media/platform/bcm2835/bcm2835-camera.c @@ -1914,8 +1914,10 @@ static int __init bm2835_mmal_init(void) for (camera = 0; camera < num_cameras; camera++) { dev = kzalloc(sizeof(struct bm2835_mmal_dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; + if (!dev) { + ret = -ENOMEM; + goto free_dev; + } dev->camera_num = camera; dev->max_width = resolutions[camera][0]; -- 2.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] staging: iio: ad9832:
Commit a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator") and commit 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'") add some dereference of 'st' which is an un-initialized pointer at this point. Re-order code and tweak error handling in order to allocate memory and have 'st' be a valid pointer before using it. Fixes: a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator") Fixes: 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'") Signed-off-by: Christophe JAILLET --- Compile tested only --- drivers/staging/iio/frequency/ad9832.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c index 639047fade30..16894836f982 100644 --- a/drivers/staging/iio/frequency/ad9832.c +++ b/drivers/staging/iio/frequency/ad9832.c @@ -211,6 +211,15 @@ static int ad9832_probe(struct spi_device *spi) return -ENODEV; } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + spi_set_drvdata(spi, indio_dev); + st = iio_priv(indio_dev); + st->mclk = pdata->mclk; + st->spi = spi; + st->avdd = devm_regulator_get(&spi->dev, "avdd"); if (IS_ERR(st->avdd)) return PTR_ERR(st->avdd); @@ -233,16 +242,6 @@ static int ad9832_probe(struct spi_device *spi) goto error_disable_avdd; } - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (!indio_dev) { - ret = -ENOMEM; - goto error_disable_dvdd; - } - spi_set_drvdata(spi, indio_dev); - st = iio_priv(indio_dev); - st->mclk = pdata->mclk; - st->spi = spi; - indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad9832_info; -- 2.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/2] staging: lustre: obdclass: Add handling of error returned by lustre_cfg_new
'lustre_cfg_new()' can return ERR_PTR(-ENOMEM). Handle these errors and propagate the error code to the callers. Error handling has been rearranged in 'lustre_process_log()' with the addition of a label in order to free some resources. Signed-off-by: Christophe JAILLET --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 59fbc29aae94..5473615cd338 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -89,11 +89,14 @@ int lustre_process_log(struct super_block *sb, char *logname, lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg)); lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb)); lcfg = lustre_cfg_new(LCFG_LOG_START, bufs); + if (IS_ERR(lcfg)) { + rc = PTR_ERR(lcfg); + goto out_free; + } + rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - kfree(bufs); - if (rc == -EINVAL) LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n", mgc->obd_name, logname, rc); @@ -104,6 +107,9 @@ int lustre_process_log(struct super_block *sb, char *logname, rc); /* class_obd_list(); */ + +out_free: + kfree(bufs); return rc; } EXPORT_SYMBOL(lustre_process_log); @@ -127,6 +133,9 @@ int lustre_end_log(struct super_block *sb, char *logname, if (cfg) lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg)); lcfg = lustre_cfg_new(LCFG_LOG_END, &bufs); + if (IS_ERR(lcfg)) + return PTR_ERR(lcfg); + rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); return rc; @@ -159,6 +168,9 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, lustre_cfg_bufs_set_string(&bufs, 4, s4); lcfg = lustre_cfg_new(cmd, &bufs); + if (IS_ERR(lcfg)) + return PTR_ERR(lcfg); + lcfg->lcfg_nid = nid; rc = class_process_config(lcfg); lustre_cfg_free(lcfg); -- 2.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 1/2] staging: lustre: obdclass: Fix error handling
'lustre_cfg_new()' does not return NULL but ERR_PTR(-ENOMEM) So IS_ERR should be used to check the return value. Signed-off-by: Christophe JAILLET --- drivers/staging/lustre/lustre/obdclass/obd_config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index bbed1b72d52e..0e922c5f8b33 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1382,8 +1382,8 @@ int class_manual_cleanup(struct obd_device *obd) lustre_cfg_bufs_reset(&bufs, obd->obd_name); lustre_cfg_bufs_set_string(&bufs, 1, flags); lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs); - if (!lcfg) - return -ENOMEM; + if (IS_ERR(lcfg)) + return PTR_ERR(lcfg); rc = class_process_config(lcfg); if (rc) { -- 2.9.3 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH] [media] s5p_cec: Fix memory allocation failure check
It is likely that checking the result of the memory allocation just above is expected here. Signed-off-by: Christophe JAILLET --- drivers/staging/media/s5p-cec/s5p_cec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c b/drivers/staging/media/s5p-cec/s5p_cec.c index 78333273c4e5..636bac182e8e 100644 --- a/drivers/staging/media/s5p-cec/s5p_cec.c +++ b/drivers/staging/media/s5p-cec/s5p_cec.c @@ -173,7 +173,7 @@ static int s5p_cec_probe(struct platform_device *pdev) int ret; cec = devm_kzalloc(&pdev->dev, sizeof(*cec), GFP_KERNEL); - if (!dev) + if (!cec) return -ENOMEM; cec->dev = dev; -- 2.7.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
[PATCH 2/2] staging: unisys: Reduce indent
Remove some extra tabs in order to improve readalibility. Signed-off-by: Christophe JAILLET --- drivers/staging/unisys/visorbus/visorbus_main.c | 49 - 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index bbc907d..36fc15d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -218,9 +218,9 @@ visorbus_release_device(struct device *xdev) struct devmajorminor_attribute { struct attribute attr; int slot; -ssize_t (*show)(struct visor_device *, int slot, char *buf); -ssize_t (*store)(struct visor_device *, int slot, const char *buf, - size_t count); + ssize_t (*show)(struct visor_device *, int slot, char *buf); + ssize_t (*store)(struct visor_device *, int slot, const char *buf, +size_t count); }; static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf) @@ -1042,10 +1042,10 @@ write_vbus_chp_info(struct visorchannel *chan, int off = sizeof(struct channel_header) + hdr_info->chp_info_offset; if (hdr_info->chp_info_offset == 0) - return -1; + return -1; if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) - return -1; + return -1; return 0; } @@ -1060,10 +1060,10 @@ write_vbus_bus_info(struct visorchannel *chan, int off = sizeof(struct channel_header) + hdr_info->bus_info_offset; if (hdr_info->bus_info_offset == 0) - return -1; + return -1; if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) - return -1; + return -1; return 0; } @@ -1080,10 +1080,10 @@ write_vbus_dev_info(struct visorchannel *chan, (hdr_info->device_info_struct_bytes * devix); if (hdr_info->dev_info_offset == 0) - return -1; + return -1; if (visorchannel_write(chan, off, info, sizeof(*info)) < 0) - return -1; + return -1; return 0; } @@ -1105,7 +1105,7 @@ fix_vbus_dev_info(struct visor_device *visordev) struct spar_vbus_headerinfo *hdr_info; if (!visordev->device.driver) - return; + return; hdr_info = (struct spar_vbus_headerinfo *)visordev->vbus_hdr_info; if (!hdr_info) @@ -1318,11 +1318,11 @@ static void pause_state_change_complete(struct visor_device *dev, int status) { if (!dev->pausing) - return; + return; dev->pausing = false; if (!chipset_responders.device_pause) /* this can never happen! */ - return; + return; /* Notify the chipset driver that the pause is complete, which * will presumably want to send some sort of response to the @@ -1338,11 +1338,11 @@ static void resume_state_change_complete(struct visor_device *dev, int status) { if (!dev->resuming) - return; + return; dev->resuming = false; if (!chipset_responders.device_resume) /* this can never happen! */ - return; + return; /* Notify the chipset driver that the resume is complete, * which will presumably want to send some sort of response to @@ -1366,14 +1366,14 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) else notify_func = chipset_responders.device_resume; if (!notify_func) - goto away; + goto away; drv = to_visor_driver(dev->device.driver); if (!drv) - goto away; + goto away; if (dev->pausing || dev->resuming) - goto away; + goto away; /* Note that even though both drv->pause() and drv->resume * specify a callback function, it is NOT necessary for us to @@ -1384,7 +1384,7 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) */ if (is_pause) { if (!drv->pause) - goto away; + goto away; dev->pausing = true; x = drv->pause(dev, pause_state_change_complete); @@ -1396,7 +1396,7 @@ initiate_chipset_device_pause_resume(struct visor_device *dev, bool is_pause) * would never even get here in that case. */ fix_vbus_dev_info(dev); if (!drv->resume) - goto away; + goto away;
[PATCH 1/2] staging: unisys: Use kzalloc instead of kmalloc/memset
This patch turns a kmalloc/memset into an equivalent kzalloc. Signed-off-by: Christophe JAILLET --- drivers/staging/unisys/visorbus/visorbus_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 6db4719..bbc907d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -281,12 +281,11 @@ devmajorminor_create_file(struct visor_device *dev, const char *name, rc = -ENOMEM; goto away; } - myattr = kmalloc(sizeof(*myattr), GFP_KERNEL); + myattr = kzalloc(sizeof(*myattr), GFP_KERNEL); if (!myattr) { rc = -ENOMEM; goto away; } - memset(myattr, 0, sizeof(struct devmajorminor_attribute)); myattr->show = DEVMAJORMINOR_ATTR; myattr->store = NULL; myattr->slot = slot; -- 2.1.4 ___ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel