device-dax: fix cdev leak
authorDan Williams <dan.j.williams@intel.com>
Fri, 17 Mar 2017 18:48:09 +0000 (12:48 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 Mar 2017 05:44:32 +0000 (06:44 +0100)
commited01e50acdd3e4a640cf9ebd28a7e810c3ceca97
tree831c42c463fbf11a2e6da50ab68b5e8854de68c2
parent233ed09d7fdacf592ee91e6c97ce5f4364fbe7c0
device-dax: fix cdev leak

If device_add() fails, cleanup the cdev. Otherwise, we leak a kobj_map()
with a stale device number.

As Jason points out, there is a small possibility that userspace has
opened and mapped the device in the time between cdev_add() and the
device_add() failure. We need a new kill_dax_dev() helper to invalidate
any established mappings.

Fixes: ba09c01d2fa8 ("dax: convert to the cdev api")
Cc: <stable@vger.kernel.org>
Reported-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/dax/dax.c