public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Gustavo Padovan <gustavo@padovan.org>, intel-gfx@lists.freedesktop.org
Cc: Gustavo Padovan <gustavo.padovan@collabora.co.uk>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/9] drm/i915: fix memleak in intel_set_config_save_state()
Date: Fri, 29 Aug 2014 10:38:43 +0300	[thread overview]
Message-ID: <87k35riw3g.fsf@intel.com> (raw)
In-Reply-To: <1409247613-14232-3-git-send-email-gustavo@padovan.org>

On Thu, 28 Aug 2014, Gustavo Padovan <gustavo@padovan.org> wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>
> If the save_encoder_crtcs or save_connector_encoders allocation fail
> we need to free everything we have already allocated.

There is no memleak, because the caller of intel_set_config_save_state()
checks the return value, and subsequently handles the error with a call
to intel_set_config_free(), which does the right thing.

I know one could argue this should be done within
intel_set_config_save_state() but I'm not convinced. I'd let this be as
it is.

Just in case Daniel disagrees with me here and wants to merge, the patch
does look correct. So r-b for correctness, but nak on merging from
me. ;)

BR,
Jani.


>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 05937fe..a8a8abe 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -11018,13 +11018,13 @@ static int intel_set_config_save_state(struct drm_device *dev,
>  		kcalloc(dev->mode_config.num_encoder,
>  			sizeof(struct drm_crtc *), GFP_KERNEL);
>  	if (!config->save_encoder_crtcs)
> -		return -ENOMEM;
> +		goto free_crtc;
>  
>  	config->save_connector_encoders =
>  		kcalloc(dev->mode_config.num_connector,
>  			sizeof(struct drm_encoder *), GFP_KERNEL);
>  	if (!config->save_connector_encoders)
> -		return -ENOMEM;
> +		goto free_encoder;
>  
>  	/* Copy data. Note that driver private data is not affected.
>  	 * Should anything bad happen only the expected state is
> @@ -11046,6 +11046,12 @@ static int intel_set_config_save_state(struct drm_device *dev,
>  	}
>  
>  	return 0;
> +
> +free_encoder:
> +	kfree(config->save_encoder_crtcs);
> +free_crtc:
> +	kfree(config->save_crtc_enabled);
> +	return -ENOMEM;
>  }
>  
>  static void intel_set_config_restore_state(struct drm_device *dev,
> -- 
> 1.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center

  reply	other threads:[~2014-08-29  7:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 17:40 [PATCH 1/9] drm/i915: init sprites with univeral plane init function Gustavo Padovan
2014-08-28 17:40 ` [PATCH 2/9] drm/i915: trivial: remove unneed set to NULL Gustavo Padovan
2014-08-29  7:28   ` Jani Nikula
2014-08-28 17:40 ` [PATCH 3/9] drm/i915: fix memleak in intel_set_config_save_state() Gustavo Padovan
2014-08-29  7:38   ` Jani Nikula [this message]
2014-08-29  7:50     ` Chris Wilson
2014-08-29 10:00       ` Jani Nikula
2014-08-28 17:40 ` [PATCH 4/9] drm/i915: split intel_update_plane into check() and commit() Gustavo Padovan
2014-08-29  7:55   ` Ville Syrjälä
2014-08-29 12:31     ` [Intel-gfx] " Daniel Vetter
2014-08-29 15:09     ` Gustavo Padovan
2014-08-29 15:38       ` Ville Syrjälä
2014-08-29 15:43         ` [Intel-gfx] " Daniel Vetter
2014-08-28 17:40 ` [PATCH 5/9] drm/i915: split intel_cursor_plane_update() " Gustavo Padovan
2014-08-28 17:40 ` [PATCH 6/9] drm/i915: split intel_crtc_cursor_set_obj() " Gustavo Padovan
2014-08-28 17:40 ` [PATCH 7/9] drm/i915: split intel_primary_plane_setplane() " Gustavo Padovan
2014-08-28 17:40 ` [PATCH 8/9] drm/i915: return error if fb is NULL Gustavo Padovan
2014-08-28 17:40 ` [PATCH 9/9] drm/i915: split intel_pipe_set_base() into check() and commit() Gustavo Padovan
2014-08-29  8:06   ` Ville Syrjälä

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k35riw3g.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo.padovan@collabora.co.uk \
    --cc=gustavo@padovan.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox