[BUG, regression] Dereferencing of NULL pointer in radeon_mn_unregister()

Jason Gunthorpe jgg at mellanox.com
Sun Sep 1 14:04:12 UTC 2019


On Sun, Sep 01, 2019 at 11:38:10AM +0200, Petr Cvek wrote:

> The code is:
> 
> 	struct radeon_mn *rmn = bo->mn;
> 	...
> 	mutex_lock(&rmn->lock);		//<-crash
> 
> A quick assert proves the bo->mn returns NULL. The code worked in
> 4.19-rc and it seems the problematic patch is

Hum, the code went away because the locking protecting that variable
went away.. It means the caller is not careful to pair register and
unregister.
 
> 	drm/radeon: use mmu_notifier_get/put for struct radeon_mn
> 
> as it removes the NULL check.
> 
> Forcing -ENODEV in the register funtion (and immediate return in
> unregister as without CONFIG_MMU_NOTIFIER) works.

Is just adding a

  if (!rmn)
       retrun

To the top of radeon_mn_unregister enough to fix it?

Jason


More information about the amd-gfx mailing list