@@ -375,13 +375,18 @@ dev_put:
static void ipu_put_resources(struct ipu_crtc *ipu_crtc)
{
- if (!IS_ERR_OR_NULL(ipu_crtc->dc))
+ if (!IS_ERR_OR_NULL(ipu_crtc->dc)) {
ipu_dc_put(ipu_crtc->dc);
- if (!IS_ERR_OR_NULL(ipu_crtc->di))
+ ipu_crtc->dc = NULL;
+ }
+ if (!IS_ERR_OR_NULL(ipu_crtc->di)) {
ipu_di_put(ipu_crtc->di);
+ ipu_crtc->di = NULL;
+ }
if (!IS_ERR_OR_NULL(ipu_crtc->ipu_dev)) {
module_put(ipu_crtc->ipu_dev->driver->owner);
put_device(ipu_crtc->ipu_dev);
+ ipu_crtc->ipu_dev = NULL;
}
}
@@ -411,6 +416,7 @@ static int ipu_get_resources(struct ipu_crtc *ipu_crtc,
ipu_crtc->di = ipu_di_get(ipu_crtc->ipu, di);
if (IS_ERR(ipu_crtc->di)) {
ret = PTR_ERR(ipu_crtc->di);
+ ipu_crtc->di = NULL;
goto err_out;
}
@@ -425,6 +431,7 @@ static int ipu_get_resources(struct ipu_crtc *ipu_crtc,
ipu_crtc->dc = ipu_dc_get(ipu_crtc->ipu, ipu_crtc->ch->dc);
if (IS_ERR(ipu_crtc->dc)) {
ret = PTR_ERR(ipu_crtc->dc);
+ ipu_crtc->dc = NULL;
goto err_out;
}
@@ -285,12 +285,18 @@ void ipu_plane_put_resources(struct ipu_plane *ipu_plane)
ipu_plane->irq, ipu_plane);
ipu_plane->irq = 0;
}
- if (!IS_ERR_OR_NULL(ipu_plane->dp))
+ if (!IS_ERR_OR_NULL(ipu_plane->dp)) {
ipu_dp_put(ipu_plane->dp);
- if (!IS_ERR_OR_NULL(ipu_plane->dmfc))
+ ipu_plane->dp = NULL;
+ }
+ if (!IS_ERR_OR_NULL(ipu_plane->dmfc)) {
ipu_dmfc_put(ipu_plane->dmfc);
- if (!IS_ERR_OR_NULL(ipu_plane->ipu_ch))
+ ipu_plane->dmfc = NULL;
+ }
+ if (!IS_ERR_OR_NULL(ipu_plane->ipu_ch)) {
ipu_idmac_put(ipu_plane->ipu_ch);
+ ipu_plane->ipu_ch = NULL;
+ }
}
int ipu_plane_get_resources(struct ipu_plane *ipu_plane)
@@ -300,6 +306,7 @@ int ipu_plane_get_resources(struct ipu_plane *ipu_plane)
ipu_plane->ipu_ch = ipu_idmac_get(ipu_plane->ipu, ipu_plane->dma);
if (IS_ERR(ipu_plane->ipu_ch)) {
ret = PTR_ERR(ipu_plane->ipu_ch);
+ ipu_plane->ipu_ch = NULL;
DRM_ERROR("failed to get idmac channel: %d\n", ret);
return ret;
}
@@ -307,6 +314,7 @@ int ipu_plane_get_resources(struct ipu_plane *ipu_plane)
ipu_plane->dmfc = ipu_dmfc_get(ipu_plane->ipu, ipu_plane->dma);
if (IS_ERR(ipu_plane->dmfc)) {
ret = PTR_ERR(ipu_plane->dmfc);
+ ipu_plane->dmfc = NULL;
DRM_ERROR("failed to get dmfc: ret %d\n", ret);
goto err_out;
}
@@ -315,6 +323,7 @@ int ipu_plane_get_resources(struct ipu_plane *ipu_plane)
ipu_plane->dp = ipu_dp_get(ipu_plane->ipu, ipu_plane->dp_flow);
if (IS_ERR(ipu_plane->dp)) {
ret = PTR_ERR(ipu_plane->dp);
+ ipu_plane->dp = NULL;
DRM_ERROR("failed to get dp flow: %d\n", ret);
goto err_out;
}
In the crtc and plane drivers it is possible the ipu unit pointers could be left at error pointer values. Reset them to NULL on errors to prevent this. Also ipu_put_resources() should reset the units to NULL after releasing them. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> --- drivers/staging/imx-drm/ipuv3-crtc.c | 11 +++++++++-- drivers/staging/imx-drm/ipuv3-plane.c | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-)