All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Jani Nikula <jani.nikula@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/6] drm/i915: add a helper to free the members of i915_params
Date: Mon, 31 Dec 2018 12:51:47 +0000	[thread overview]
Message-ID: <55f6c768-a864-c7c3-1451-c81610c60620@linux.intel.com> (raw)
In-Reply-To: <8637d1e5049dc003718772f19d664aeaf9540856.1545920737.git.jani.nikula@intel.com>


On 27/12/2018 14:33, Jani Nikula wrote:
> Abstract the one user in anticipation of more. Set the dangling pointers
> to NULL while at it.
> 
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gpu_error.c |  9 +--------
>   drivers/gpu/drm/i915/i915_params.c    | 16 ++++++++++++++++
>   drivers/gpu/drm/i915/i915_params.h    |  1 +
>   3 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
> index 8c04479c1586..2bd7991ec9af 100644
> --- a/drivers/gpu/drm/i915/i915_gpu_error.c
> +++ b/drivers/gpu/drm/i915/i915_gpu_error.c
> @@ -963,17 +963,10 @@ static void i915_error_object_free(struct drm_i915_error_object *obj)
>   	kfree(obj);
>   }
>   
> -static __always_inline void free_param(const char *type, void *x)
> -{
> -	if (!__builtin_strcmp(type, "char *"))
> -		kfree(*(void **)x);
> -}
>   
>   static void cleanup_params(struct i915_gpu_state *error)
>   {
> -#define FREE(T, x, ...) free_param(#T, &error->params.x);
> -	I915_PARAMS_FOR_EACH(FREE);
> -#undef FREE
> +	i915_params_free(&error->params);
>   }
>   
>   static void cleanup_uc_state(struct i915_gpu_state *error)
> diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c
> index ae3ece4ec7ab..81c73bfc7991 100644
> --- a/drivers/gpu/drm/i915/i915_params.c
> +++ b/drivers/gpu/drm/i915/i915_params.c
> @@ -217,3 +217,19 @@ void i915_params_copy(struct i915_params *dest, const struct i915_params *src)
>   	I915_PARAMS_FOR_EACH(DUP);
>   #undef DUP
>   }
> +
> +static __always_inline void free_param(const char *type, void *x)
> +{
> +	if (!__builtin_strcmp(type, "char *")) {
> +		kfree(*(void **)x);
> +		*(void **)x = NULL;
> +	}
> +}
> +
> +/* free the allocated members, *not* the passed in params itself */
> +void i915_params_free(struct i915_params *params)
> +{
> +#define FREE(T, x, ...) free_param(#T, &params->x);
> +	I915_PARAMS_FOR_EACH(FREE);
> +#undef FREE
> +}
> diff --git a/drivers/gpu/drm/i915/i915_params.h b/drivers/gpu/drm/i915/i915_params.h
> index fd1cf9415e60..93f665eced16 100644
> --- a/drivers/gpu/drm/i915/i915_params.h
> +++ b/drivers/gpu/drm/i915/i915_params.h
> @@ -79,6 +79,7 @@ extern struct i915_params i915_modparams __read_mostly;
>   
>   void i915_params_dump(const struct i915_params *params, struct drm_printer *p);
>   void i915_params_copy(struct i915_params *dest, const struct i915_params *src);
> +void i915_params_free(struct i915_params *params);
>   
>   #endif
>   
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-12-31 12:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-27 14:33 [PATCH 0/6] drm/i915: modparam rework prep work Jani Nikula
2018-12-27 14:33 ` [PATCH 1/6] drm/i915: add a helper to make a copy of i915_params Jani Nikula
2018-12-27 14:33 ` [PATCH 2/6] drm/i915: add a helper to free the members " Jani Nikula
2018-12-31 12:51   ` Tvrtko Ursulin [this message]
2018-12-27 14:33 ` [PATCH 3/6] drm/i915/uc: add dev_priv parameter to intel_uc_is_using_* functions Jani Nikula
2018-12-31 12:56   ` Tvrtko Ursulin
2018-12-27 14:33 ` [PATCH 4/6] drm/i915/params: set i915.enable_hangcheck permissions to 0600 Jani Nikula
2018-12-31 13:01   ` Tvrtko Ursulin
2018-12-31 13:31     ` Jani Nikula
2018-12-27 14:33 ` [PATCH 5/6] drm/i915: move load failure injection to selftests Jani Nikula
2018-12-31 13:13   ` Tvrtko Ursulin
2018-12-31 13:18     ` Chris Wilson
2018-12-31 15:12       ` Jani Nikula
2018-12-31 15:16         ` Chris Wilson
2018-12-27 14:33 ` [PATCH 6/6] drm/i915/params: document I915_PARAMS_FOR_EACH() Jani Nikula
2018-12-31 13:05   ` Tvrtko Ursulin
2018-12-31 13:24     ` Jani Nikula
2018-12-31 15:07       ` Tvrtko Ursulin
2018-12-31 15:16         ` Jani Nikula
2018-12-27 14:59 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: modparam rework prep work Patchwork
2018-12-27 15:02 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-12-27 15:20 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-12-28  8:59 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: modparam rework prep work (rev2) Patchwork
2018-12-28  9:02 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-12-28  9:35 ` ✓ Fi.CI.BAT: success " Patchwork
2018-12-28 11:06 ` ✓ Fi.CI.IGT: " Patchwork

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=55f6c768-a864-c7c3-1451-c81610c60620@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.