stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: tang.junhui@zte.com.cn
Cc: agk@redhat.com, dm-devel@redhat.com, bmarzins@redhat.com,
	zhang.kai16@zte.com.cn, stable@vger.kernel.org
Subject: Re: md/dm-table: tgt->type should be putted in dm_table_add_target()
Date: Thu, 20 Oct 2016 22:16:35 -0400	[thread overview]
Message-ID: <20161021021635.GA7605@redhat.com> (raw)
In-Reply-To: <1477013732-4800-1-git-send-email-tang.junhui@zte.com.cn>

On Thu, Oct 20 2016 at  9:35pm -0400,
tang.junhui@zte.com.cn <tang.junhui@zte.com.cn> wrote:

> From: "tang.junhui" <tang.junhui@zte.com.cn>
> 
> tgt->type should be putted in dm_table_add_target()
> when the target do not statisfy the needs of target type,
> otherwise it would cause the module reference count
> of this target type leakage.
> 
> Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
> Cc: stable@vger.kernel.org

This issue, missing dm_put_target_type, dates back to 2011.

See these 3 commits:
$ git log --oneline 3791e2fc0^..36a0456fb
36a0456 dm table: add immutable feature
cc6cbe1 dm table: add always writeable feature
3791e2f dm table: add singleton feature

So are you having problems with failed DM table loads (due to the errors
below) resulting in the inability to unload a DM module?

(BTW, you don't need to cc stable when initially proposing a patch for
stable.  The stable@ maintainers will automatically pull such stable@
changes in once they land in Linus' tree.)

Mike

> ---
>  drivers/md/dm-table.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 6554d91..4f56c38 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -698,30 +698,30 @@ int dm_table_add_target(struct dm_table *t, const char *type,
>  
>  	if (dm_target_needs_singleton(tgt->type)) {
>  		if (t->num_targets) {
> -			DMERR("%s: target type %s must appear alone in table",
> -			      dm_device_name(t->md), type);
> -			return -EINVAL;
> +			tgt->error = "target type must appear alone in table";
> +			r = -EINVAL;
> +			goto bad;
>  		}
>  		t->singleton = 1;
>  	}
>  
>  	if (dm_target_always_writeable(tgt->type) && !(t->mode & FMODE_WRITE)) {
> -		DMERR("%s: target type %s may not be included in read-only tables",
> -		      dm_device_name(t->md), type);
> -		return -EINVAL;
> +		tgt->error = "target type may not be included in read-only tables";
> +		r = -EINVAL;
> +		goto bad;
>  	}
>  
>  	if (t->immutable_target_type) {
>  		if (t->immutable_target_type != tgt->type) {
> -			DMERR("%s: immutable target type %s cannot be mixed with other target types",
> -			      dm_device_name(t->md), t->immutable_target_type->name);
> -			return -EINVAL;
> +			tgt->error = "immutable target type cannot be mixed with other target types";
> +			r = -EINVAL;
> +			goto bad;
>  		}
>  	} else if (dm_target_is_immutable(tgt->type)) {
>  		if (t->num_targets) {
> -			DMERR("%s: immutable target type %s cannot be mixed with other target types",
> -			      dm_device_name(t->md), tgt->type->name);
> -			return -EINVAL;
> +			tgt->error = "immutable target type cannot be mixed with other target types";
> +			r = -EINVAL;
> +			goto bad;
>  		}
>  		t->immutable_target_type = tgt->type;
>  	}
> -- 
> 2.8.1.windows.1
> 

      reply	other threads:[~2016-10-21  2:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-21  1:35 [PATCH] md/dm-table: tgt->type should be putted in dm_table_add_target() tang.junhui
2016-10-21  2:16 ` Mike Snitzer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161021021635.GA7605@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tang.junhui@zte.com.cn \
    --cc=zhang.kai16@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).