All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>, intel-gfx@lists.freedesktop.org
Subject: Re: [RESEND 5/6] drm/i915: Remove pci private pointer after destroying the device private
Date: Mon, 16 Jul 2018 11:04:20 +0100	[thread overview]
Message-ID: <ad9f2b1c-e208-8a78-d96e-ef2eb1914929@linux.intel.com> (raw)
In-Reply-To: <20180716080332.32283-5-chris@chris-wilson.co.uk>


On 16/07/2018 09:03, Chris Wilson wrote:
> On an aborted module load, we unwind and free our device private - but
> we left a dangling pointer to our privates inside the pci_device. After
> the attempted aborted unload, we may still get a call to i915_pci_remove()
> when the module is removed, potentially chasing stale data.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>   drivers/gpu/drm/i915/i915_drv.c |  1 +
>   drivers/gpu/drm/i915/i915_pci.c | 13 ++++++++++++-
>   2 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index 700ffb611187..3834bd758a2e 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1424,6 +1424,7 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	drm_dev_fini(&dev_priv->drm);
>   out_free:
>   	kfree(dev_priv);
> +	pci_set_drvdata(pdev, NULL);
>   	return ret;
>   }
>   
> diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
> index 55543f1b0236..6a4d1388ad2d 100644
> --- a/drivers/gpu/drm/i915/i915_pci.c
> +++ b/drivers/gpu/drm/i915/i915_pci.c
> @@ -674,10 +674,16 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
>   
>   static void i915_pci_remove(struct pci_dev *pdev)
>   {
> -	struct drm_device *dev = pci_get_drvdata(pdev);
> +	struct drm_device *dev;
> +
> +	dev = pci_get_drvdata(pdev);
> +	if (!dev) /* driver load aborted, nothing to cleanup */
> +		return;
>   
>   	i915_driver_unload(dev);
>   	drm_dev_put(dev);
> +
> +	pci_set_drvdata(pdev, NULL);
>   }
>   
>   static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
> @@ -712,6 +718,11 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>   	if (err)
>   		return err;
>   
> +	if (i915_inject_load_failure()) {
> +		i915_pci_remove(pdev);
> +		return -ENODEV;
> +	}
> +
>   	err = i915_live_selftests(pdev);
>   	if (err) {
>   		i915_pci_remove(pdev);
> 

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-07-16 10:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16  8:03 [RESEND 1/6] drm/i915/selftests: Force a preemption hang Chris Wilson
2018-07-16  8:03 ` [RESEND 2/6] drm/i915/selftests: Exercise reset to break stuck GTT eviction Chris Wilson
2018-07-16  9:32   ` Tvrtko Ursulin
2018-07-16  8:03 ` [RESEND 3/6] drm/i915/execlists: Always clear preempt status on cancelling all Chris Wilson
2018-07-16  9:45   ` Tvrtko Ursulin
2018-07-16  8:03 ` [RESEND 4/6] drm/i915/execlists: Disable submission tasklet upon wedging Chris Wilson
2018-07-16  9:59   ` Tvrtko Ursulin
2018-07-16  8:03 ` [RESEND 5/6] drm/i915: Remove pci private pointer after destroying the device private Chris Wilson
2018-07-16 10:04   ` Tvrtko Ursulin [this message]
2018-07-16 10:32   ` Michal Wajdeczko
2018-07-16 10:37     ` Chris Wilson
2018-07-16  8:03 ` [RESEND 6/6] drm/i915/selftests: Downgrade igt_timeout message Chris Wilson
2018-07-16 10:06   ` Tvrtko Ursulin
2018-07-16  8:32 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [RESEND,1/6] drm/i915/selftests: Force a preemption hang Patchwork
2018-07-16  8:53 ` ✓ Fi.CI.BAT: success " Patchwork
2018-07-16  9:08 ` [RESEND 1/6] " Tvrtko Ursulin
2018-07-16 15:04 ` ✓ Fi.CI.IGT: success for series starting with [RESEND,1/6] " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2018-07-16  7:22 [RESEND 1/6] " Chris Wilson
2018-07-16  7:22 ` [RESEND 5/6] drm/i915: Remove pci private pointer after destroying the device private Chris Wilson

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=ad9f2b1c-e208-8a78-d96e-ef2eb1914929@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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 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.