0452-drm-vc4-clean-up-error-exit-path-on-failed-dpi_conne.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. From f594ac854025bc377a8b2095e9be41af96eed278 Mon Sep 17 00:00:00 2001
  2. From: Colin Ian King <colin.king@canonical.com>
  3. Date: Thu, 2 Jun 2016 10:38:29 +0100
  4. Subject: [PATCH] drm/vc4: clean up error exit path on failed dpi_connector
  5. allocation
  6. There is redundant code in the clean up exit path when dpi_connector
  7. fails to be allocated. The current code checks if connector is NULL
  8. before destroying it, in fact, connector is NULL at this point so
  9. the check is redundant and can be removed. The final clean up is
  10. that we can remove the goto fail with a simple return and the unused
  11. variable ret.
  12. Signed-off-by: Colin Ian King <colin.king@canonical.com>
  13. Reviewed-by: Eric Anholt <eric@anholt.net>
  14. (cherry picked from commit a9402dfe17bddeee5c72943385eaa13c39f106f7)
  15. ---
  16. drivers/gpu/drm/vc4/vc4_dpi.c | 14 +++-----------
  17. 1 file changed, 3 insertions(+), 11 deletions(-)
  18. --- a/drivers/gpu/drm/vc4/vc4_dpi.c
  19. +++ b/drivers/gpu/drm/vc4/vc4_dpi.c
  20. @@ -236,14 +236,12 @@ static struct drm_connector *vc4_dpi_con
  21. {
  22. struct drm_connector *connector = NULL;
  23. struct vc4_dpi_connector *dpi_connector;
  24. - int ret = 0;
  25. dpi_connector = devm_kzalloc(dev->dev, sizeof(*dpi_connector),
  26. GFP_KERNEL);
  27. - if (!dpi_connector) {
  28. - ret = -ENOMEM;
  29. - goto fail;
  30. - }
  31. + if (!dpi_connector)
  32. + return ERR_PTR(-ENOMEM);
  33. +
  34. connector = &dpi_connector->base;
  35. dpi_connector->encoder = dpi->encoder;
  36. @@ -260,12 +258,6 @@ static struct drm_connector *vc4_dpi_con
  37. drm_mode_connector_attach_encoder(connector, dpi->encoder);
  38. return connector;
  39. -
  40. - fail:
  41. - if (connector)
  42. - vc4_dpi_connector_destroy(connector);
  43. -
  44. - return ERR_PTR(ret);
  45. }
  46. static const struct drm_encoder_funcs vc4_dpi_encoder_funcs = {