<tt><font size=2>Hello, Mike</font></tt>
<br>
<br><font size=2 face="sans-serif">Thanks for your quick respond. </font>
<br><font size=2 face="sans-serif">This problem causes failure in "rmmod
dm-spp" command,</font>
<br><font size=2 face="sans-serif">(dm-spp is a tagert type for our product)</font>
<br><font size=2 face="sans-serif">since the </font><tt><font size=2>reference
count</font></tt><font size=2 face="sans-serif"> is not zero due to </font>
<br><font size=2 face="sans-serif">the failure of </font><tt><font size=2>DM
table loads</font></tt><font size=2 face="sans-serif">.</font>
<br>
<br><font size=2 face="sans-serif">I don't intend to cc </font><tt><font size=2>stable</font></tt><font size=2 face="sans-serif">,
I just add the </font>
<br><font size=2>"Cc: stable@vger.kernel.org" after </font><tt><font size=2>Signed-off-by</font></tt><font size=2>
in</font>
<br><font size=2>commit message as Bart suggested it to me, then I send
email</font>
<br><font size=2>by "git send-email" command, and it cc to </font><tt><font size=2>stable</font></tt><font size=2>
automatically,</font>
<br><font size=2>I think maybe my git is not configured well, I'll research
it </font>
<br><font size=2>later.</font>
<br>
<br><tt><font size=2>(BTW, I like your name, Mike, Thank you for your </font></tt><font size=2>accompanying</font><tt><font size=2>
</font></tt>
<br><tt><font size=2>with us in our English class for so many years.)</font></tt><font size=2>
</font>
<br>
<br><font size=2>thanks,</font>
<br>
<br><font size=2>Tang</font>
<br><font size=2> </font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">发件人:    
    </font><font size=1 face="sans-serif">Mike Snitzer
<snitzer@redhat.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">收件人:    
    </font><font size=1 face="sans-serif">tang.junhui@zte.com.cn,
</font>
<br><font size=1 color=#5f5f5f face="sans-serif">抄送:    
   </font><font size=1 face="sans-serif">zhang.kai16@zte.com.cn,
dm-devel@redhat.com, stable@vger.kernel.org, agk@redhat.com</font>
<br><font size=1 color=#5f5f5f face="sans-serif">日期:    
    </font><font size=1 face="sans-serif">2016/10/21
10:24</font>
<br><font size=1 color=#5f5f5f face="sans-serif">主题:    
   </font><font size=1 face="sans-serif">Re: [dm-devel]
md/dm-table: tgt->type should be putted in        dm_table_add_target()</font>
<br><font size=1 color=#5f5f5f face="sans-serif">发件人:    
   </font><font size=1 face="sans-serif">dm-devel-bounces@redhat.com</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>On Thu, Oct 20 2016 at  9:35pm -0400,<br>
tang.junhui@zte.com.cn <tang.junhui@zte.com.cn> wrote:<br>
<br>
> From: "tang.junhui" <tang.junhui@zte.com.cn><br>
> <br>
> tgt->type should be putted in dm_table_add_target()<br>
> when the target do not statisfy the needs of target type,<br>
> otherwise it would cause the module reference count<br>
> of this target type leakage.<br>
> <br>
> Signed-off-by: tang.junhui <tang.junhui@zte.com.cn><br>
> Cc: stable@vger.kernel.org<br>
<br>
This issue, missing dm_put_target_type, dates back to 2011.<br>
<br>
See these 3 commits:<br>
$ git log --oneline 3791e2fc0^..36a0456fb<br>
36a0456 dm table: add immutable feature<br>
cc6cbe1 dm table: add always writeable feature<br>
3791e2f dm table: add singleton feature<br>
<br>
So are you having problems with failed DM table loads (due to the errors<br>
below) resulting in the inability to unload a DM module?<br>
<br>
(BTW, you don't need to cc stable when initially proposing a patch for<br>
stable.  The stable@ maintainers will automatically pull such stable@<br>
changes in once they land in Linus' tree.)<br>
<br>
Mike<br>
<br>
> ---<br>
>  drivers/md/dm-table.c | 24 ++++++++++++------------<br>
>  1 file changed, 12 insertions(+), 12 deletions(-)<br>
> <br>
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c<br>
> index 6554d91..4f56c38 100644<br>
> --- a/drivers/md/dm-table.c<br>
> +++ b/drivers/md/dm-table.c<br>
> @@ -698,30 +698,30 @@ int dm_table_add_target(struct dm_table *t,
const char *type,<br>
>  <br>
>                  
if (dm_target_needs_singleton(tgt->type)) {<br>
>                  
                 if
(t->num_targets) {<br>
> -                
                 
               
DMERR("%s: target type %s must appear alone in table",<br>
> -                
                 
               
      dm_device_name(t->md), type);<br>
> -                
                 
               
return -EINVAL;<br>
> +                
                 
               
tgt->error = "target type must appear alone in table";<br>
> +                
                 
               
r = -EINVAL;<br>
> +                
                 
               
goto bad;<br>
>                  
                 }<br>
>                  
                 t->singleton
= 1;<br>
>                  
}<br>
>  <br>
>                  
if (dm_target_always_writeable(tgt->type) && !(t->mode &
FMODE_WRITE)) {<br>
> -                
                 DMERR("%s:
target type %s may not be included in read-only tables",<br>
> -                
                 
     dm_device_name(t->md), type);<br>
> -                
                 return
-EINVAL;<br>
> +                
                 tgt->error
= "target type may not be included in read-only tables";<br>
> +                
                 r
= -EINVAL;<br>
> +                
                 goto
bad;<br>
>                  
}<br>
>  <br>
>                  
if (t->immutable_target_type) {<br>
>                  
                 if
(t->immutable_target_type != tgt->type) {<br>
> -                
                 
               
DMERR("%s: immutable target type %s cannot be mixed with other target
types",<br>
> -                
                 
               
      dm_device_name(t->md), t->immutable_target_type->name);<br>
> -                
                 
               
return -EINVAL;<br>
> +                
                 
               
tgt->error = "immutable target type cannot be mixed with other
target types";<br>
> +                
                 
               
r = -EINVAL;<br>
> +                
                 
               
goto bad;<br>
>                  
                 }<br>
>                  
} else if (dm_target_is_immutable(tgt->type)) {<br>
>                  
                 if
(t->num_targets) {<br>
> -                
                 
               
DMERR("%s: immutable target type %s cannot be mixed with other target
types",<br>
> -                
                 
               
      dm_device_name(t->md), tgt->type->name);<br>
> -                
                 
               
return -EINVAL;<br>
> +                
                 
               
tgt->error = "immutable target type cannot be mixed with other
target types";<br>
> +                
                 
               
r = -EINVAL;<br>
> +                
                 
               
goto bad;<br>
>                  
                 }<br>
>                  
                 t->immutable_target_type
= tgt->type;<br>
>                  
}<br>
> -- <br>
> 2.8.1.windows.1<br>
> <br>
<br>
--<br>
dm-devel mailing list<br>
dm-devel@redhat.com<br>
</font></tt><a href="https://www.redhat.com/mailman/listinfo/dm-devel"><tt><font size=2>https://www.redhat.com/mailman/listinfo/dm-devel</font></tt></a><tt><font size=2><br>
</font></tt>
<br>