dm table: fix missing dm_put_target_type() in dm_table_add_target()
authortang.junhui <tang.junhui@zte.com.cn>
Fri, 21 Oct 2016 01:35:32 +0000 (09:35 +0800)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 23 Feb 2017 03:50:54 +0000 (03:50 +0000)
commite97631eb2f76c43a1167d52cb368167a8377996d
tree1206462ed1f0b7b2bd91abdeb8b1f2c8a6a95558
parentde9a7cc6c067303161f2db55a0e716b6406c9a09
dm table: fix missing dm_put_target_type() in dm_table_add_target()

commit dafa724bf582181d9a7d54f5cb4ca0bf8ef29269 upstream.

dm_get_target_type() was previously called so any error returned from
dm_table_add_target() must first call dm_put_target_type().  Otherwise
the DM target module's reference count will leak and the associated
kernel module will be unable to be removed.

Also, leverage the fact that r is already -EINVAL and remove an extra
newline.

Fixes: 36a0456 ("dm table: add immutable feature")
Fixes: cc6cbe1 ("dm table: add always writeable feature")
Fixes: 3791e2f ("dm table: add singleton feature")
Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[bwh: Backported to 3.2: adjuat context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/md/dm-table.c