devres: fix devres_get()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 15 Jul 2015 01:29:00 +0000 (10:29 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Sep 2015 17:00:09 +0000 (10:00 -0700)
commit 64526370d11ce8868ca495723d595b61e8697fbf upstream.

Currently, devres_get() passes devres_free() the pointer to devres,
but devres_free() should be given with the pointer to resource data.

Fixes: 9ac7849e35f7 ("devres: device resource management")
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/devres.c

index 507379e7b763781816ae5e4c65858b3b0b977a7b..4e2fb405da871e88cde1bb5bf65208442ea5dde1 100644 (file)
@@ -296,10 +296,10 @@ void * devres_get(struct device *dev, void *new_res,
        if (!dr) {
                add_dr(dev, &new_dr->node);
                dr = new_dr;
-               new_dr = NULL;
+               new_res = NULL;
        }
        spin_unlock_irqrestore(&dev->devres_lock, flags);
-       devres_free(new_dr);
+       devres_free(new_res);
 
        return dr->data;
 }