Re: [PATCH] [v2] nvdimm-btt: fix several memleaks

2023-12-20 Thread dinghao . liu
> dinghao.liu@ wrote: > > > Ira Weiny wrote: > > > > Dinghao Liu wrote: [snip] > > > > > > > > This does not quite work. > > > > > > > > free_arenas() is used in the error paths of create_arenas() and > >

Re: [PATCH] [v2] nvdimm-btt: fix several memleaks

2023-12-18 Thread dinghao . liu
> Ira Weiny wrote: > > Dinghao Liu wrote: > > [snip] > > -static int btt_freelist_init(struct arena_info *arena) > +static int btt_freelist_init(struct device *dev, struct arena_info *arena) > > Both struct arena_info and struct btt contain references to struct nd

[PATCH] [v2] nvdimm-btt: simplify code with the scope based resource management

2023-12-14 Thread Dinghao Liu
Use the scope based resource management (defined in linux/cleanup.h) to automate resource lifetime control on struct btt_sb *super in discover_arenas(). Signed-off-by: Dinghao Liu --- Changelog: v2: Set the __free attribute before kzalloc. --- drivers/nvdimm/btt.c | 13 - 1 file

Re: [PATCH] nvdimm-btt: simplify code with the scope based resource management

2023-12-13 Thread dinghao . liu
> > It's a little strange that we do not check super immediately after > > allocation. > > How about this: > > > > static int discover_arenas(struct btt *btt) > > { > > int ret = 0; > > struct arena_info *arena; > > - struct btt_sb *super; > > size_t remaining =

Re: [PATCH] nvdimm-btt: simplify code with the scope based resource management

2023-12-12 Thread dinghao . liu
> > On 12/10/23 03:27, Dinghao Liu wrote: > > Use the scope based resource management (defined in > > linux/cleanup.h) to automate resource lifetime > > control on struct btt_sb *super in discover_arenas(). > > > > Signed-off-by: Dinghao Liu &g

[PATCH] nvdimm-btt: simplify code with the scope based resource management

2023-12-10 Thread Dinghao Liu
Use the scope based resource management (defined in linux/cleanup.h) to automate resource lifetime control on struct btt_sb *super in discover_arenas(). Signed-off-by: Dinghao Liu --- drivers/nvdimm/btt.c | 12 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers

[PATCH] [v2] nvdimm-btt: fix several memleaks

2023-12-10 Thread Dinghao Liu
->freelist a leaked memory. Fix these memleaks by using devm_kcalloc() to make the memory auto-freed on driver detach. Fixes: 5212e11fde4d ("nd_btt: atomic sector updates") Signed-off-by: Dinghao Liu --- Changelog: v2: -Use devm_kcalloc() to fix the memleaks. -Fix the potential

Re: [PATCH] nvdimm-btt: fix a potential memleak in btt_freelist_init

2023-12-09 Thread dinghao . liu
> dinghao.liu@ wrote: > > > Dave Jiang wrote: > > [snip] > > > > That said, this patch does not completely fix freelist from leaking in the > > > following error path. > > > > > > discover_arenas() > > > btt_freelist_init() -> ok (memory allocated) > > > btt_rtt_init() ->

Re: [PATCH] nvdimm-btt: fix a potential memleak in btt_freelist_init

2023-12-07 Thread dinghao . liu
> Dave Jiang wrote: > > > > [snip] > > First off thanks for the patch. This code seems to have a few things to > clean up. > > > > > On 12/6/23 20:43, Dinghao Liu wrote: > > > When an error happens in btt_freelist_init(), its caller > &g

[PATCH] nvdimm-btt: fix a potential memleak in btt_freelist_init

2023-12-06 Thread Dinghao Liu
quot;nd_btt: atomic sector updates") Signed-off-by: Dinghao Liu --- drivers/nvdimm/btt.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index d5593b0dc700..d8c4ba8bfdda 100644 --- a/drivers/nvdimm/btt.c +++ b/driv

[PATCH] [v4] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-10-06 Thread Dinghao Liu
54: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: Dinghao Liu --- Changelog: v2: -Remove the first clk_unregister() instead of nulling priv->clk. v3: -Simplify ca8210_register_ext_clock(). -Add a ';' after return in ca8210_unregister_ext_clock(). v4: -Remove an unused variab

Re: [PATCH] [v3] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-10-06 Thread dinghao . liu
rc3 next-20230929] > > [If your patch is applied to the wrong git tree, kindly drop us a note. > > And when submitting patch, we suggest to use '--base' as documented in > > https://git-scm.com/docs/git-format-patch#_base_tree_information] > > > > url: > > https://gith

[PATCH] [v3] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-09-30 Thread Dinghao Liu
54: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: Dinghao Liu --- Changelog: v2: -Remove the first clk_unregister() instead of nulling priv->clk. v3: -Simplify ca8210_register_ext_clock(). -Add a ';' after return in ca8210_unregister_ext_clock(). --- drivers/net/ie

Re: [PATCH] [v2] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-09-26 Thread dinghao . liu
> Missing Cc stable, this needs to be backported. I will cc stable (sta...@vger.kernel.org) for the next version, thanks! > > diff --git a/drivers/net/ieee802154/ca8210.c > > b/drivers/net/ieee802154/ca8210.c > > index aebb19f1b3a4..b35c6f59bd1a 100644 > > --- a/drivers/net/ieee802154/ca8210.c >

[PATCH] [v2] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-09-25 Thread Dinghao Liu
54: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: Dinghao Liu --- Changelog: v2: -Remove the first clk_unregister() instead of nulling priv->clk. --- drivers/net/ieee802154/ca8210.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ieee802154/

Re: [PATCH] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-09-25 Thread dinghao . liu
Hi Miquèl, > > index aebb19f1b3a4..1d545879c000 100644 > > --- a/drivers/net/ieee802154/ca8210.c > > +++ b/drivers/net/ieee802154/ca8210.c > > @@ -2760,6 +2760,7 @@ static int ca8210_register_ext_clock(struct > > spi_device *spi) > > ret = of_clk_add_provider(np, of_clk_src_simple_get,

[PATCH] ieee802154: ca8210: Fix a potential UAF in ca8210_probe

2023-09-25 Thread Dinghao Liu
ee may happen in the second time we call clk_unregister(). Fix this by nulling priv->clk after the first clk_unregister(). Also refine the pointer checking in ca8210_unregister_ext_clock(). Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver") Signed-off-by: Dingha

[PATCH] [v4] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe

2021-04-15 Thread Dinghao Liu
pport") Signed-off-by: Dinghao Liu --- Changelog: v2: - Add a refcount increment to fix refcout leak instead of the refcount decrement on error. Set ctlr->auto_runtime_pm = true. v3: - Add fix tag. Add a return value check against pm_runtime_get_sync(). Mov

[PATCH] [v3] clk: renesas: rcar-usb2-clock-sel: Fix error handling in rcar_usb2_clock_sel_probe

2021-04-15 Thread Dinghao Liu
The error handling paths after pm_runtime_get_sync() has no refcount decrement, which leads to refcount leak. Signed-off-by: Dinghao Liu --- Changelog: v2: - Move the position of pm_runtime_enable,_get_sync(). Use devm_clk_register() to simplify error handling. v2: - Use

[PATCH] [v3] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe

2021-04-15 Thread Dinghao Liu
pport") Signed-off-by: Dinghao Liu --- Changelog: v2: - Add a refcount increment to fix refcout leak instead of the refcount decrement on error. Set ctlr->auto_runtime_pm = true. v3: - Add fix tag. Add a return value check against pm_runtime_get_sync(). Mov

Re: Re: [PATCH] [v2] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe

2021-04-14 Thread dinghao . liu
> Hi Dinghao, > On Mon, Apr 12, 2021 at 03:31:54PM +0800, Dinghao Liu wrote: > > There is a PM usage counter decrement after zynqmp_qspi_init_hw() > > without any refcount increment, which leads to refcount leak.Add > > a refcount increment to balance the refcount. Also

[PATCH] clk: renesas: rcar-usb2-clock-sel: Fix error handling in rcar_usb2_clock_sel_probe

2021-04-12 Thread Dinghao Liu
When clk_get_rate() fails, a pairing PM usage counter decrement and disable is required to prevent refcount leak. It's the same for the subsequent error paths. When of_clk_add_hw_provider() fails, we need to unregister clk_hw. Signed-off-by: Dinghao Liu --- drivers/clk/renesas/rcar-usb2-clock

[PATCH] [v2] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe

2021-04-12 Thread Dinghao Liu
There is a PM usage counter decrement after zynqmp_qspi_init_hw() without any refcount increment, which leads to refcount leak.Add a refcount increment to balance the refcount. Also set auto_runtime_pm to resume suspended spi controller. Signed-off-by: Dinghao Liu --- changelog: v2: - Add

[PATCH] [v2] usb: cdns3: Fix runtime PM imbalance on error

2021-04-11 Thread Dinghao Liu
When cdns3_gadget_start() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. Signed-off-by: Dinghao Liu --- Changelog: v2: - Use pm_runtime_put_sync() to decrease refcount. --- drivers/usb/cdns3/cdns3-gadget.c | 4 +++- 1 file changed, 3 insertions(+), 1

Re: Re: [PATCH] usb: cdns3: Fix rumtime PM imbalance on error

2021-04-11 Thread dinghao . liu
> On 21-04-07 13:22:26, Dinghao Liu wrote: > > When cdns3_gadget_start() fails, a pairing PM usage counter > > decrement is needed to keep the counter balanced. > > > > Signed-off-by: Dinghao Liu > > --- > > drivers/usb/cdns3/cdns3-gadget.c | 5 -

[PATCH] [v2] iio: proximity: pulsedlight: Fix rumtime PM imbalance on error

2021-04-11 Thread Dinghao Liu
When lidar_write_control() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. Fixes: 4ac4e086fd8c5 ("iio: pulsedlight-lidar-lite: add runtime PM") Signed-off-by: Dinghao Liu --- Changelog: v2: - Add the fix tag. --- drivers/iio/proximity/pulsedlight-

[PATCH] [v2] dmaengine: tegra20: Fix runtime PM imbalance on error

2021-04-09 Thread Dinghao Liu
pm_runtime_get_sync() will increase the runtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

Re: Re: [PATCH] dmaengine: tegra20: Fix runtime PM imbalance in tegra_dma_issue_pending

2021-04-09 Thread dinghao . liu
> On 08/04/2021 08:11, Dinghao Liu wrote: > > pm_runtime_get_sync() will increase the rumtime PM counter > > even it returns an error. Thus a pairing decrement is needed > > to prevent refcount leak. Fix this by replacing this API with > > pm_runtime_resume_and_g

[PATCH] [v2] media: imx: imx7-mipi-csis: Fix runtime PM imbalance in mipi_csis_s_stream

2021-04-09 Thread Dinghao Liu
When v4l2_subdev_call() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. It's the same for the following error paths in case 'enable' is on. Signed-off-by: Dinghao Liu --- Changelog: v2: - Use pm_runtime_put() to balance the refcount. --- drivers/staging

Re: Re: [PATCH] media: imx: imx7-mipi-csis: Fix runtime PM imbalance in mipi_csis_s_stream

2021-04-09 Thread dinghao . liu
> Hi Liu, > Thanks for your patch. > > On Thu, Apr 08, 2021 at 05:08:27PM +0800, Dinghao Liu wrote: > > When v4l2_subdev_call() fails, a pairing PM usage counter > > decrement is needed to keep the counter balanced. It's the > > same for the followi

Re: Re: [PATCH] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe

2021-04-09 Thread dinghao . liu
> Hi Dinghao, > > On 4/8/21 6:33 PM, Michal Simek wrote: > > ++ > > > > On 4/8/21 11:25 AM, Dinghao Liu wrote: > >> When platform_get_irq() fails, a pairing PM usage counter > >> increment is needed to keep the counter balanced. It's the > >>

[PATCH] spi: spi-zynqmp-gqspi: Fix runtime PM imbalance in zynqmp_qspi_probe

2021-04-08 Thread Dinghao Liu
When platform_get_irq() fails, a pairing PM usage counter increment is needed to keep the counter balanced. It's the same for the following error paths. Signed-off-by: Dinghao Liu --- drivers/spi/spi-zynqmp-gqspi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-zynqmp

[PATCH] media: imx: imx7-mipi-csis: Fix runtime PM imbalance in mipi_csis_s_stream

2021-04-08 Thread Dinghao Liu
When v4l2_subdev_call() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. It's the same for the following error paths in case 'enable' is on. Signed-off-by: Dinghao Liu --- drivers/staging/media/imx/imx7-mipi-csis.c | 9 +++-- 1 file changed, 7 insertions

[PATCH] media: atomisp: Fix runtime PM imbalance in atomisp_pci_probe

2021-04-08 Thread Dinghao Liu
When hmm_pool_register() fails, a pairing PM usage counter increment is needed to keep the counter balanced. It's the same for the following error paths. Signed-off-by: Dinghao Liu --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers

[PATCH] PCI: tegra: Fix runtime PM imbalance in pex_ep_event_pex_rst_deassert

2021-04-08 Thread Dinghao Liu
pm_runtime_get_sync() will increase the runtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] PCI: rcar: Fix runtime PM imbalance in rcar_pcie_ep_probe

2021-04-08 Thread Dinghao Liu
pm_runtime_get_sync() will increase the runtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] slimbus: qcom-ngd-ctrl: Fix runtime PM imbalance in qcom_slim_ngd_enable

2021-04-08 Thread Dinghao Liu
When slim_register_controller() fails, a pairing PM usage counter increment is needed to keep the counter balanced. Signed-off-by: Dinghao Liu --- drivers/slimbus/qcom-ngd-ctrl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/slimbus/qcom-ngd-ctrl.c b/drivers/slimbus/qcom-ngd

[PATCH] dmaengine: tegra20: Fix runtime PM imbalance in tegra_dma_issue_pending

2021-04-08 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] media: ti-vpe: cal: Fix runtime PM imbalance in cal_probe

2021-04-08 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] media: atomisp: Fix error handling in atomisp_open

2021-04-08 Thread Dinghao Liu
Some error paths in atomisp_open will execute PM runtime decrement and unregister hmm pool even before we increase the PM refcount and registration. Fix this by adjusting jump labels on error. Signed-off-by: Dinghao Liu --- drivers/staging/media/atomisp/pci/atomisp_fops.c | 5 +++-- 1 file

[PATCH] [v2] ASoC: codecs: Fix runtime PM imbalance in tas2552_probe

2021-04-08 Thread Dinghao Liu
There is a rumtime PM imbalance between the error handling path after devm_snd_soc_register_component() and all other error handling paths. Add a PM runtime increment to balance refcount. Signed-off-by: Dinghao Liu --- Changelog: v2: - Add a PM runtime increment to fix it instead of moving

Re: Re: [PATCH] Input: cyapa - Fix rumtime PM imbalance on error

2021-04-08 Thread dinghao . liu
> Hi Dinghao, > > On Wed, Apr 07, 2021 at 12:07:38PM +0800, Dinghao Liu wrote: > > When mutex_lock_interruptible() fails, a pairing PM usage > > counter decrement is needed to keep the counter balanced. > > Thank you for the patch. > > > > > Signed

Re: Re: [PATCH] ASoC: codecs: Fix rumtime PM imbalance in tas2552_probe

2021-04-07 Thread dinghao . liu
> On Wed, Apr 07, 2021 at 02:54:00PM +0800, Dinghao Liu wrote: > > > - pm_runtime_set_active(>dev); > > - pm_runtime_set_autosuspend_delay(>dev, 1000); > > - pm_runtime_use_autosuspend(>dev); > > - pm_runtime_enable(>de

[PATCH] ASoC: codecs: Fix rumtime PM imbalance in tas2552_probe

2021-04-07 Thread Dinghao Liu
There is a rumtime PM imbalance between the error handling path after devm_snd_soc_register_component() and all other error handling paths. Fix this by moving PM runtime decrement to the end of the function. Signed-off-by: Dinghao Liu --- sound/soc/codecs/tas2552.c | 14 +++--- 1 file

[PATCH] media: sun8i-di: Fix rumtime PM imbalance in deinterlace_start_streaming

2021-04-06 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] media: platform: sti: Fix rumtime PM imbalance in regs_show

2021-04-06 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] dmaengine: stm32: Fix rumtime PM imbalance in stm32_dmamux_resume

2021-04-06 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] usb: cdns3: Fix rumtime PM imbalance on error

2021-04-06 Thread Dinghao Liu
When cdns3_gadget_start() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. Signed-off-by: Dinghao Liu --- drivers/usb/cdns3/cdns3-gadget.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb

[PATCH] mfd: arizona: Fix rumtime PM imbalance on error

2021-04-06 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] iio: proximity: pulsedlight: Fix rumtime PM imbalance on error

2021-04-06 Thread Dinghao Liu
When lidar_write_control() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. Signed-off-by: Dinghao Liu --- drivers/iio/proximity/pulsedlight-lidar-lite-v2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c

[PATCH] Input: cyapa - Fix rumtime PM imbalance on error

2021-04-06 Thread Dinghao Liu
When mutex_lock_interruptible() fails, a pairing PM usage counter decrement is needed to keep the counter balanced. Signed-off-by: Dinghao Liu --- drivers/input/mouse/cyapa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/input/mouse/cyapa.c b/drivers/input/mouse

[PATCH] iio: light: gp2ap002: Fix rumtime PM imbalance on error

2021-04-06 Thread Dinghao Liu
When devm_request_threaded_irq() fails, we should decrease the runtime PM counter to keep the counter balanced. But when iio_device_register() fails, we need not to decrease it because we have already decreased it before. Signed-off-by: Dinghao Liu --- drivers/iio/light/gp2ap002.c | 5 +++-- 1

[PATCH] i2c: omap: Fix rumtime PM imbalance on error

2021-04-06 Thread Dinghao Liu
pm_runtime_get_sync() will increase the rumtime PM counter even it returns an error. Thus a pairing decrement is needed to prevent refcount leak. Fix this by replacing this API with pm_runtime_resume_and_get(), which will not change the runtime PM counter on error. Signed-off-by: Dinghao Liu

[PATCH] hostap: Fix memleak in prism2_config

2021-03-29 Thread Dinghao Liu
When prism2_hw_config() fails, we just return an error code without any resource release, which may lead to memleak. Signed-off-by: Dinghao Liu --- drivers/net/wireless/intersil/hostap/hostap_cs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless

[PATCH] scsi: aic7xxx: aic79xx: Add missing check in ahc_handle_seqint

2021-03-10 Thread Dinghao Liu
ahc_lookup_scb() may return a null pointer and further lead to null-pointer-dereference in case DATA_OVERRUN. Fix this by adding a null check. Signed-off-by: Dinghao Liu --- drivers/scsi/aic7xxx/aic7xxx_core.c | 72 +++-- 1 file changed, 37 insertions(+), 35 deletions

[PATCH] media: em28xx: Fix missing check in em28xx_capture_start

2021-03-10 Thread Dinghao Liu
There are several em28xx_write_reg() and em28xx_write_reg_bits() calls that we have caught their return values but lack further handling. Check and return error on failure just like other calls in em28xx_capture_start(). Signed-off-by: Dinghao Liu --- drivers/media/usb/em28xx/em28xx-core.c | 9

[PATCH] power: supply: axp20x_usb_power: Add missing check in axp20x_usb_power_probe

2021-03-03 Thread Dinghao Liu
There are two regmap_update_bits() calls but only one of them has return value check, which is odd. Add a return value check and terminate the execution flow on failure just like the other call. Signed-off-by: Dinghao Liu --- drivers/power/supply/axp20x_usb_power.c | 4 +++- 1 file changed, 3

[PATCH] [v2] sata_dwc_460ex: Fix missing check in sata_dwc_isr

2021-03-03 Thread Dinghao Liu
The return value of ata_qc_from_tag() is checked in the whole kernel except for two calls in sata_dwc_isr(), which may lead to null-pointer-dereference. Add return value checks to avoid such case. Signed-off-by: Dinghao Liu --- Changelog: v2: - Refine commit message. Add return value

Re: Re: Re: Re: [PATCH] sata_dwc_460ex: Fix missing check in sata_dwc_isr

2021-03-03 Thread dinghao . liu
> On Tue, Mar 2, 2021 at 9:34 AM wrote: > > > On Mon, Mar 1, 2021 at 1:20 PM wrote: > > > > > On Mon, Mar 1, 2021 at 9:44 AM Dinghao Liu > > > > > wrote: > > ... > > > > > This issue is reported by my static analys

Re: Re: Re: [PATCH] sata_dwc_460ex: Fix missing check in sata_dwc_isr

2021-03-02 Thread dinghao . liu
> On Mon, Mar 1, 2021 at 1:20 PM wrote: > > > > > On Mon, Mar 1, 2021 at 9:44 AM Dinghao Liu wrote: > > > > > > > > ata_qc_from_tag() may return a null pointer and further lead to > > > > null-pointer-dereference. Add a return value check

[PATCH] drivers: misc: ad525x_dpot: Add missing check in dpot_read_spi

2021-03-01 Thread Dinghao Liu
The use of dpot_read_r8d8() after checking dpot->uid is similar. However, we check the return value and return an error code only in one path, which is odd. Signed-off-by: Dinghao Liu --- drivers/misc/ad525x_dpot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/m

Re: Re: [PATCH] tpm: Add missing check in tpm_inf_recv

2021-03-01 Thread dinghao . liu
Jarkko Sakkinen jar...@kernel.org写道: > On Sun, Feb 28, 2021 at 05:32:30PM +0800, Dinghao Liu wrote: > > The use of wait() in tpm_inf_recv() is almost the same. It's odd that > > we only check the return value and terminate execution flow of one call. > > > >

Re: Re: [PATCH] sata_dwc_460ex: Fix missing check in sata_dwc_isr

2021-03-01 Thread dinghao . liu
> On Mon, Mar 1, 2021 at 9:44 AM Dinghao Liu wrote: > > > > ata_qc_from_tag() may return a null pointer and further lead to > > null-pointer-dereference. Add a return value check to avoid such case. > > Can you elaborate more on this? Is it a real case? > I have a

[PATCH] scsi: aic7xxx: aic79xx: Add missing check in ahd_handle_seqint

2021-03-01 Thread Dinghao Liu
ahd_lookup_scb() may return a null pointer and further lead to null pointer dereference in case DATA_OVERRUN. Fix this by adding a null check. Signed-off-by: Dinghao Liu --- drivers/scsi/aic7xxx/aic79xx_core.c | 44 +++-- 1 file changed, 23 insertions(+), 21 deletions

[PATCH] iio: adc: Fix error handling in vadc_do_conversion

2021-03-01 Thread Dinghao Liu
There is one vadc_poll_wait_eoc() call in vadc_do_conversion that we have caught its return value but lack further handling. Check and jump to err_disable label just like the other vadc_poll_wait_eoc() in this function. Signed-off-by: Dinghao Liu --- drivers/iio/adc/qcom-spmi-vadc.c | 2 ++ 1

[PATCH] iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler

2021-03-01 Thread Dinghao Liu
There is one regmap_bulk_read() call in mpu3050_trigger_handler that we have caught its return value bug lack further handling. Check and terminate the execution flow just like the other three regmap_bulk_read() calls in this function. Signed-off-by: Dinghao Liu --- drivers/iio/gyro/mpu3050

Re: Re: [PATCH] iwlegacy: Add missing check in il4965_commit_rxon

2021-02-28 Thread dinghao . liu
> On Sun, Feb 28, 2021 at 08:25:22PM +0800, Dinghao Liu wrote: > > There is one il_set_tx_power() call in this function without > > return value check. Print error message and return error code > > on failure just like the other il_set_tx_power() call. > > We have fe

[PATCH] sata_dwc_460ex: Fix missing check in sata_dwc_isr

2021-02-28 Thread Dinghao Liu
ata_qc_from_tag() may return a null pointer and further lead to null-pointer-dereference. Add a return value check to avoid such case. Signed-off-by: Dinghao Liu --- drivers/ata/sata_dwc_460ex.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/ata

[PATCH] iwlegacy: Add missing check in il4965_commit_rxon

2021-02-28 Thread Dinghao Liu
There is one il_set_tx_power() call in this function without return value check. Print error message and return error code on failure just like the other il_set_tx_power() call. Signed-off-by: Dinghao Liu --- drivers/net/wireless/intel/iwlegacy/4965.c | 6 +- 1 file changed, 5 insertions

[PATCH] i40e: Fix error handling in i40e_vsi_open

2021-02-28 Thread Dinghao Liu
When vsi->type == I40E_VSI_FDIR, we have caught the return value of i40e_vsi_request_irq() but without further handling. Check and execute memory clean on failure just like the other i40e_vsi_request_irq(). Fixes: 8a9eb7d3cbcab ("i40e: rework fdir setup and teardown") Signed-off-by

[PATCH] e1000e: Fix error handling in e1000_set_d0_lplu_state_82571

2021-02-28 Thread Dinghao Liu
There is one e1e_wphy() call in e1000_set_d0_lplu_state_82571 that we have caught its return value but lack further handling. Check and terminate the execution flow just like other e1e_wphy() in this function. Signed-off-by: Dinghao Liu --- drivers/net/ethernet/intel/e1000e/82571.c | 2 ++ 1

[PATCH] tpm: Add missing check in tpm_inf_recv

2021-02-28 Thread Dinghao Liu
The use of wait() in tpm_inf_recv() is almost the same. It's odd that we only check the return value and terminate execution flow of one call. Signed-off-by: Dinghao Liu --- drivers/char/tpm/tpm_infineon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm

Re: Re: [PATCH] RDMA/siw: Fix missing check in siw_get_hdr

2021-02-26 Thread dinghao . liu
Bernard Metzler b...@zurich.ibm.com写道: > -----"Dinghao Liu" wrote: - > > >To: dinghao@zju.edu.cn, k...@umn.edu > >From: "Dinghao Liu" > >Date: 02/26/2021 08:56AM > >Cc: "Bernard Metzler" , "Doug Ledford"

[PATCH] mmc: sdhci-pci-o2micro: Add missing checks in sdhci_pci_o2_probe

2021-02-26 Thread Dinghao Liu
It's odd to adopt different error handling on failure of pci_read_config_dword(). Check the return value and terminate execution flow on failure of all pci_read_config_dword() calls in this function. Signed-off-by: Dinghao Liu --- drivers/mmc/host/sdhci-pci-o2micro.c | 8 1 file

[PATCH] RDMA/siw: Fix missing check in siw_get_hdr

2021-02-25 Thread Dinghao Liu
We should also check the range of opcode after calling __rdmap_get_opcode() in the else branch to prevent potential overflow. Fixes: 8b6a361b8c482 ("rdma/siw: receive path") Signed-off-by: Dinghao Liu --- drivers/infiniband/sw/siw/siw_qp_rx.c | 10 ++ 1 file changed, 10

Re: Re: [PATCH] ASoC: Intel: Skylake: Fix missing check in skl_pcm_trigger

2021-02-18 Thread dinghao . liu
> > On 2/15/21 7:13 AM, Dinghao Liu wrote: > > When cmd == SNDRV_PCM_TRIGGER_STOP, we should also check > > the return value of skl_decoupled_trigger() just like what > > we have done in case SNDRV_PCM_TRIGGER_PAUSE_RELEASE. > > > > Signed-off-by: Dinghao Liu

[PATCH] ASoC: Intel: Skylake: Fix missing check in skl_pcm_trigger

2021-02-15 Thread Dinghao Liu
When cmd == SNDRV_PCM_TRIGGER_STOP, we should also check the return value of skl_decoupled_trigger() just like what we have done in case SNDRV_PCM_TRIGGER_PAUSE_RELEASE. Signed-off-by: Dinghao Liu --- sound/soc/intel/skylake/skl-pcm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound

[PATCH] ALSA: intel8x0: Fix missing check in snd_intel8x0m_create

2021-01-31 Thread Dinghao Liu
When device_type == DEVICE_ALI, we should also check the return value of pci_iomap() to avoid potential null pointer dereference. Signed-off-by: Dinghao Liu --- sound/pci/intel8x0m.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/pci/intel8x0m.c b/sound/pci

[PATCH] extcon: Fix error handling in extcon_dev_register

2021-01-19 Thread Dinghao Liu
When devm_kcalloc() fails, we should execute device_unregister() to unregister edev->dev from system. Fixes: 046050f6e623e ("extcon: Update the prototype of extcon_register_notifier() with enum extcon") Signed-off-by: Dinghao Liu --- drivers/extcon/extcon.c | 1 + 1 file changed

[PATCH] [v3] block: Fix an error handling in add_partition

2021-01-17 Thread Dinghao Liu
Once we have called device_initialize(), we should use put_device() to give up the reference on error, just like what we have done on failure of device_add(). Signed-off-by: Dinghao Liu --- Changelog: v2: - Refine commit message. v3: - Add '[v3]' to the title. --- block/partitions/core.c | 2

[PATCH] block: Fix an error handling in add_partition

2021-01-17 Thread Dinghao Liu
Once we have called device_initialize(), we should use put_device() to give up the reference on error, just like what we have done on failure of device_add(). Signed-off-by: Dinghao Liu --- Changelog: v2: - Refine commit message. --- block/partitions/core.c | 2 +- 1 file changed, 1 insertion

Re: Re: [PATCH] block: Fix an error handling in add_partition

2021-01-16 Thread dinghao . liu
> On 1/15/21 11:34 PM, Dinghao Liu wrote: > > Once we have called device_initialize(), we should > > use put_device() to give up the reference on error, > > just like what we have done on failure of device_add(). > > > > Signed-off-by: Dinghao Liu > Please cons

[PATCH] block: Fix an error handling in add_partition

2021-01-15 Thread Dinghao Liu
Once we have called device_initialize(), we should use put_device() to give up the reference on error, just like what we have done on failure of device_add(). Signed-off-by: Dinghao Liu --- block/partitions/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block

[PATCH] [v2] evm: Fix memleak in init_desc

2021-01-10 Thread Dinghao Liu
When kmalloc() fails, tmp_tfm allocated by crypto_alloc_shash() has not been freed, which leads to memleak. Fixes: d46eb3699502b ("evm: crypto hash replaced by shash") Signed-off-by: Dinghao Liu --- Changelog: v2: - Remove checks against tmp_tfm before freeing. --- security/int

Re: Re: Re: [PATCH] evm: Fix memleak in init_desc

2021-01-09 Thread dinghao . liu
> On Sun, Jan 10, 2021 at 01:27:09PM +0800, dinghao@zju.edu.cn wrote: > > > On Sat, Jan 09, 2021 at 07:33:05PM +0800, Dinghao Liu wrote: > > > > When kmalloc() fails, tmp_tfm allocated by > > > > crypto_alloc_shash() has not been freed, which > > &g

Re: Re: [PATCH] evm: Fix memleak in init_desc

2021-01-09 Thread dinghao . liu
> On Sat, Jan 09, 2021 at 07:33:05PM +0800, Dinghao Liu wrote: > > When kmalloc() fails, tmp_tfm allocated by > > crypto_alloc_shash() has not been freed, which > > leads to memleak. > > > > Fixes: d46eb3699502b ("evm: crypto hash replaced by

[PATCH] netfilter: Fix memleak in nf_nat_init

2021-01-09 Thread Dinghao Liu
When register_pernet_subsys() fails, nf_nat_bysource should be freed just like when nf_ct_extend_register() fails. Fixes: 1cd472bf036ca ("netfilter: nf_nat: add nat hook register functions to nf_nat") Signed-off-by: Dinghao Liu --- net/netfilter/nf_nat_core.c | 1 + 1 file changed, 1

[PATCH] evm: Fix memleak in init_desc

2021-01-09 Thread Dinghao Liu
When kmalloc() fails, tmp_tfm allocated by crypto_alloc_shash() has not been freed, which leads to memleak. Fixes: d46eb3699502b ("evm: crypto hash replaced by shash") Signed-off-by: Dinghao Liu --- security/integrity/evm/evm_crypto.c | 9 +++-- 1 file changed, 7 insertions(+), 2

Re: Re: [PATCH] media: v4l2: Fix memleak in videobuf_read_one

2021-01-08 Thread dinghao . liu
> On 05/01/2021 08:59, Dinghao Liu wrote: > > When videobuf_waiton() fails, we should execute clean > > functions to prevent memleak. It's the same when > > __videobuf_copy_to_user() fails. > > > > Fixes: 7a7d9a89d0307 ("V4L/DVB (6251): Replace vid

Re: Re: [PATCH] net: ethernet: Fix memleak in ethoc_probe

2021-01-06 Thread dinghao . liu
> On Wed, 6 Jan 2021 18:56:23 +0800 (GMT+08:00) dinghao@zju.edu.cn > wrote: > > > I used this one for a test: > > > > > > https://patchwork.kernel.org/project/netdevbpf/patch/1609312994-121032-1-git-send-email-abaci-bug...@linux.alibaba.com/ > > > > > > I'm not getting the Fixes tag when I

Re: Re: [PATCH] net: ethernet: Fix memleak in ethoc_probe

2021-01-06 Thread dinghao . liu
> On Mon, 28 Dec 2020 16:14:17 -0500 Konstantin Ryabitsev wrote: > > On Mon, Dec 28, 2020 at 01:05:26PM -0800, Florian Fainelli wrote: > > > On 12/28/2020 12:23 PM, Konstantin Ryabitsev wrote: > > > > On Thu, Dec 24, 2020 at 01:57:40PM -0800, Florian Fainelli wrote: > > > Konstantin,

[PATCH] media: v4l2: Fix memleak in videobuf_read_one

2021-01-05 Thread Dinghao Liu
When videobuf_waiton() fails, we should execute clean functions to prevent memleak. It's the same when __videobuf_copy_to_user() fails. Fixes: 7a7d9a89d0307 ("V4L/DVB (6251): Replace video-buf to a more generic approach") Signed-off-by: Dinghao Liu --- drivers/media/v4l2-core/video

[PATCH] ubifs: Fix memleak in ubifs_init_authentication

2021-01-04 Thread Dinghao Liu
When crypto_shash_digestsize() fails, c->hmac_tfm has not been freed before returning, which leads to memleak. Fixes: 49525e5eecca5 ("ubifs: Add helper functions for authentication support") Signed-off-by: Dinghao Liu --- fs/ubifs/auth.c | 2 +- 1 file changed, 1 insertion(+

[PATCH] [v2] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-04 Thread Dinghao Liu
When irq_domain_get_irq_data() or irqd_cfg() fails at i == 0, data allocated by kzalloc() has not been freed before returning, which leads to memleak. Fixes: b106ee63abccb ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical irqdomains") Signed-off-by: D

Re: Re: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-04 Thread dinghao . liu
> On 1/3/21 2:22 PM, dinghao@zju.edu.cn wrote: > >> On 2021/1/3 12:08, dinghao@zju.edu.cn wrote: > >>>> Hi, > >>>> > >>>> On 2021/1/2 17:50, Dinghao Liu wrote: > >>>>> When irq_domain_get_irq_data() or

Re: Re: [Intel-wired-lan] [PATCH] net: ixgbe: Fix memleak in ixgbe_configure_clsu32

2021-01-03 Thread dinghao . liu
> Dear Dinghao, > > > Am 03.01.21 um 09:08 schrieb Dinghao Liu: > > When ixgbe_fdir_write_perfect_filter_82599() fails, > > input allocated by kzalloc() has not been freed, > > which leads to memleak. > > Nice find. Thank you for your patches. Out of curio

[PATCH] net: ixgbe: Fix memleak in ixgbe_configure_clsu32

2021-01-03 Thread Dinghao Liu
When ixgbe_fdir_write_perfect_filter_82599() fails, input allocated by kzalloc() has not been freed, which leads to memleak. Signed-off-by: Dinghao Liu --- drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net

Re: Re: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-02 Thread dinghao . liu
> On 2021/1/3 12:08, dinghao@zju.edu.cn wrote: > >> Hi, > >> > >> On 2021/1/2 17:50, Dinghao Liu wrote: > >>> When irq_domain_get_irq_data() or irqd_cfg() fails > >>> meanwhile i == 0, data allocated by kzalloc() has not >

Re: Re: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-02 Thread dinghao . liu
> Hi, > > On 2021/1/2 17:50, Dinghao Liu wrote: > > When irq_domain_get_irq_data() or irqd_cfg() fails > > meanwhile i == 0, data allocated by kzalloc() has not > > been freed before returning, which leads to memleak. > > > > Fixes: b106ee63abccb ("

[PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-02 Thread Dinghao Liu
When irq_domain_get_irq_data() or irqd_cfg() fails meanwhile i == 0, data allocated by kzalloc() has not been freed before returning, which leads to memleak. Fixes: b106ee63abccb ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical irqdomains") Signed-off-by: D

  1   2   3   4   >