media: platform: stm32-csi: Add missing media_entity_cleanup()
Subsystems (12)
PATCH v2 6/22 media: platform: stm32-csi: Add missing media_entity_cleanup()
The media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/st/stm32/stm32-csi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/st/stm32/stm32-csi.c +2 -0
@@ -1060,6 +1060,7 @@ static int stm32_csi_probe(struct platform_device *pdev) err_cleanup:v4l2_async_nf_cleanup (&csidev->notifier); +media_entity_cleanup (&csidev->sd.entity);return ret; }
@@ -1068,6 +1069,7 @@ static void stm32_csi_remove(struct platform_device *pdev)struct stm32_csi_dev *csidev =platform_get_drvdata (pdev);v4l2_async_unregister_subdev (&csidev->sd); +media_entity_cleanup (&csidev->sd.entity);pm_runtime_disable (&pdev->dev); }
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 8/22 media: platform: microchip-isc-scaler: Add missing media_entity_cleanup()
The media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/microchip/microchip-isc-scaler.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/platform/microchip/microchip-isc-scaler.c +7 -0
@@ -222,6 +222,7 @@ int isc_scaler_init(struct isc_device *isc) ret =v4l2_device_register_subdev (&isc->v4l2_dev, &isc->scaler_sd);if (ret <0 ) {dev_err (isc->dev,"scaler sd failed to register subdev\n" ); +media_entity_cleanup (&isc->scaler_sd.entity);return ret; }
@@ -229,6 +230,12 @@ int isc_scaler_init(struct isc_device *isc) }EXPORT_SYMBOL_GPL (isc_scaler_init); +void isc_scaler_unregister (struct isc_device *isc) +{ +media_entity_cleanup (&isc->scaler_sd.entity); +} +EXPORT_SYMBOL_GPL (isc_scaler_unregister); +int isc_scaler_link (struct isc_device *isc) {int ret;
Signature · 6 lines
2.50.1 (Apple Git-155) drivers/media/platform/microchip/microchip-isc-base.c | 1 + drivers/media/platform/microchip/microchip-isc.h | 1 + 2 files changed, 2 insertions(+)
drivers/media/platform/microchip/microchip-isc-base.c +1 -0
@@ -1949,6 +1949,7 @@ EXPORT_SYMBOL_GPL(isc_mc_init);void isc_mc_cleanup (struct isc_device *isc) { +isc_scaler_unregister (isc);media_entity_cleanup (&isc->video_dev.entity);media_device_cleanup (&isc->mdev); }
drivers/media/platform/microchip/microchip-isc.h +1 -0
@@ -392,6 +392,7 @@ void microchip_isc_clk_cleanup(struct isc_device *isc);int isc_scaler_link (struct isc_device *isc);int isc_scaler_init (struct isc_device *isc); +void isc_scaler_unregister (struct isc_device *isc);int isc_mc_init (struct isc_device *isc,u32 ver);void isc_mc_cleanup (struct isc_device *isc);
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 9/22 media: platform: cdns-csi2tx: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/cadence/cdns-csi2tx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/cadence/cdns-csi2tx.c +4 -1
@@ -620,7 +620,7 @@ static int csi2tx_probe(struct platform_device *pdev) ret =v4l2_async_register_subdev (&csi2tx->subdev);if (ret <0 ) - goto err_free_priv; + goto err_entity_cleanup; dev_info(&pdev->dev, "Probed CSI2TX with %u/%u lanes, %u streams, %s D-PHY\n",
@@ -629,6 +629,8 @@ static int csi2tx_probe(struct platform_device *pdev)return 0 ; +err_entity_cleanup: +media_entity_cleanup (&csi2tx->subdev.entity); err_free_priv:kfree (csi2tx);return ret;
@@ -639,6 +641,7 @@ static void csi2tx_remove(struct platform_device *pdev)struct csi2tx_priv *csi2tx =platform_get_drvdata (pdev);v4l2_async_unregister_subdev (&csi2tx->subdev); +media_entity_cleanup (&csi2tx->subdev.entity);kfree (csi2tx); }
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 10/22 media: platform: rcar-csi2: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/renesas/rcar-csi2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/renesas/rcar-csi2.c +2 -0
@@ -2634,6 +2634,7 @@ static int rcsi2_probe(struct platform_device *pdev) error_async:v4l2_async_nf_unregister (&priv->notifier);v4l2_async_nf_cleanup (&priv->notifier); +media_entity_cleanup (&priv->subdev.entity);return ret; }
@@ -2646,6 +2647,7 @@ static void rcsi2_remove(struct platform_device *pdev)v4l2_async_nf_cleanup (&priv->notifier);v4l2_async_unregister_subdev (&priv->subdev);v4l2_subdev_cleanup (&priv->subdev); +media_entity_cleanup (&priv->subdev.entity);pm_runtime_disable (&pdev->dev); }
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 11/22 media: platform: csisp: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/renesas/rcar-isp/csisp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/renesas/rcar-isp/csisp.c +2 -0
@@ -556,6 +556,7 @@ static int risp_probe(struct platform_device *pdev)v4l2_async_nf_cleanup (&isp->notifier); error_pm:pm_runtime_disable (&pdev->dev); +media_entity_cleanup (&isp->subdev.entity);return ret; }
@@ -569,6 +570,7 @@ static void risp_remove(struct platform_device *pdev)v4l2_async_unregister_subdev (&isp->subdev);v4l2_subdev_cleanup (&isp->subdev); +media_entity_cleanup (&isp->subdev.entity);pm_runtime_disable (&pdev->dev); }
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 14/22 media: platform: cfe: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/raspberrypi/rp1-cfe/cfe.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/raspberrypi/rp1-cfe/cfe.c +2 -0
@@ -2039,6 +2039,7 @@ static int cfe_register_node(struct cfe_device *cfe, int id)if (ret) {cfe_err (cfe,"Unable to register video device %s\n" , vdev->name); +media_entity_cleanup (&vdev->entity);return ret; }
@@ -2064,6 +2065,7 @@ static void cfe_unregister_nodes(struct cfe_device *cfe)if (check_state (cfe,NODE_REGISTERED , i)) {clear_state (cfe,NODE_REGISTERED , i);video_unregister_device (&node->video_dev); +media_entity_cleanup (&node->video_dev.entity); } } }
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 15/22 media: platform: j721e-csi2rx: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/ti/j721e-csi2rx/j721e-csi2rx.c +5 -1
@@ -1079,13 +1079,16 @@ static int ti_csi2rx_v4l2_init(struct ti_csi2rx_dev *csi) csi->v4l2_dev.mdev = mdev; ret =v4l2_device_register (csi->dev, &csi->v4l2_dev); -if (ret) +if (ret) { +media_entity_cleanup (&csi->vdev.entity);return ret; + } ret =media_device_register (mdev);if (ret) {v4l2_device_unregister (&csi->v4l2_dev);media_device_cleanup (mdev); +media_entity_cleanup (&csi->vdev.entity);return ret; }
@@ -1105,6 +1108,7 @@ static void ti_csi2rx_cleanup_v4l2(struct ti_csi2rx_dev *csi)media_device_unregister (&csi->mdev);v4l2_device_unregister (&csi->v4l2_dev);media_device_cleanup (&csi->mdev); +media_entity_cleanup (&csi->vdev.entity); }static void ti_csi2rx_cleanup_subdev (struct ti_csi2rx_dev *csi)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 16/22 media: platform: hantro_drv: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/platform/verisilicon/hantro_drv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/media/platform/verisilicon/hantro_drv.c +9 -3
@@ -771,8 +771,10 @@ static int hantro_register_entity(struct media_device *mdev,return ret; ret =media_device_register_entity (mdev, entity); -if (ret) +if (ret) { +media_entity_cleanup (entity);return ret; + }return 0 ; }
@@ -860,12 +862,13 @@ static int hantro_attach_func(struct hantro_dev *vpu, err_rel_entity2:media_device_unregister_entity (&func->sink); - +media_entity_cleanup (&func->sink); err_rel_entity1:media_device_unregister_entity (&func->proc); - +media_entity_cleanup (&func->proc); err_rel_entity0:media_device_unregister_entity (&func->vdev.entity); +media_entity_cleanup (&func->vdev.entity);return ret; }
@@ -878,6 +881,9 @@ static void hantro_detach_func(struct hantro_func *func)media_device_unregister_entity (&func->sink);media_device_unregister_entity (&func->proc);media_device_unregister_entity (&func->vdev.entity); +media_entity_cleanup (&func->sink); +media_entity_cleanup (&func->proc); +media_entity_cleanup (&func->vdev.entity); }static int hantro_add_func (struct hantro_dev *vpu,unsigned int funcid)
Signature · 1 line
2.50.1 (Apple Git-155)
PATCH v2 21/22 media: usb: dvb-usb-v2: Add missing media_entity_cleanup()
In reply to Biren PandyaThe media_entity_pads_init() (or media_entity_init()) function initializes the media entity, but the driver forgets to call media_entity_cleanup() in the error paths and remove function. Add the missing calls to fix the API violation and prevent potential future memory leaks.
--- drivers/media/usb/dvb-usb-v2/mxl111sf.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/media/usb/dvb-usb-v2/mxl111sf.c +20 -1
@@ -900,8 +900,21 @@ static int mxl111sf_attach_tuner(struct dvb_usb_adapter *adap)return ret; ret =media_device_register_entity (mdev, &state->tuner); -if (ret) +if (ret) { +media_entity_cleanup (&state->tuner);return ret; + } +#endif +return 0 ; +} + +static int mxl111sf_detach_tuner (struct dvb_usb_adapter *adap) +{ +struct mxl111sf_state *state =adap_to_priv (adap); + +#ifdef CONFIG_MEDIA_CONTROLLER_DVB +media_device_unregister_entity (&state->tuner); +media_entity_cleanup (&state->tuner);#endif return 0 ; }
@@ -1093,6 +1106,7 @@ static struct dvb_usb_device_properties mxl111sf_props_dvbt = { .i2c_algo = &mxl111sf_i2c_algo, .frontend_attach = mxl111sf_frontend_attach_dvbt, .tuner_attach = mxl111sf_attach_tuner, + .tuner_detach = mxl111sf_detach_tuner, .init = mxl111sf_init, .streaming_ctrl = mxl111sf_ep4_streaming_ctrl, .get_stream_config = mxl111sf_get_stream_config_dvbt,
@@ -1135,6 +1149,7 @@ static struct dvb_usb_device_properties mxl111sf_props_atsc = { .i2c_algo = &mxl111sf_i2c_algo, .frontend_attach = mxl111sf_frontend_attach_atsc, .tuner_attach = mxl111sf_attach_tuner, + .tuner_detach = mxl111sf_detach_tuner, .init = mxl111sf_init, .streaming_ctrl = mxl111sf_ep6_streaming_ctrl, .get_stream_config = mxl111sf_get_stream_config_atsc,
@@ -1177,6 +1192,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mh = { .i2c_algo = &mxl111sf_i2c_algo, .frontend_attach = mxl111sf_frontend_attach_mh, .tuner_attach = mxl111sf_attach_tuner, + .tuner_detach = mxl111sf_detach_tuner, .init = mxl111sf_init, .streaming_ctrl = mxl111sf_ep5_streaming_ctrl, .get_stream_config = mxl111sf_get_stream_config_mh,
@@ -1246,6 +1262,7 @@ static struct dvb_usb_device_properties mxl111sf_props_atsc_mh = { .i2c_algo = &mxl111sf_i2c_algo, .frontend_attach = mxl111sf_frontend_attach_atsc_mh, .tuner_attach = mxl111sf_attach_tuner, + .tuner_detach = mxl111sf_detach_tuner, .init = mxl111sf_init, .streaming_ctrl = mxl111sf_streaming_ctrl_atsc_mh, .get_stream_config = mxl111sf_get_stream_config_atsc_mh,
@@ -1325,6 +1342,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mercury = { .i2c_algo = &mxl111sf_i2c_algo, .frontend_attach = mxl111sf_frontend_attach_mercury, .tuner_attach = mxl111sf_attach_tuner, + .tuner_detach = mxl111sf_detach_tuner, .init = mxl111sf_init, .streaming_ctrl = mxl111sf_streaming_ctrl_mercury, .get_stream_config = mxl111sf_get_stream_config_mercury,
@@ -1396,6 +1414,7 @@ static struct dvb_usb_device_properties mxl111sf_props_mercury_mh = { .i2c_algo = &mxl111sf_i2c_algo, .frontend_attach = mxl111sf_frontend_attach_mercury_mh, .tuner_attach = mxl111sf_attach_tuner, + .tuner_detach = mxl111sf_detach_tuner, .init = mxl111sf_init, .streaming_ctrl = mxl111sf_streaming_ctrl_mercury_mh, .get_stream_config = mxl111sf_get_stream_config_mercury_mh,
Signature · 1 line
2.50.1 (Apple Git-155)