mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Lawrence <joe.lawrence@redhat.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Jiri Kosina <jikos@kernel.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Jessica Yu <jeyu@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	Chris J Arges <chris.j.arges@canonical.com>,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] livepatch: __klp_disable_patch() should never be called for disabled patches
Date: Tue, 24 Oct 2017 10:27:23 -0400	[thread overview]
Message-ID: <20171024142723.l5e7v2f7ckrlkbrc@redhat.com> (raw)
In-Reply-To: <1508511411-4189-3-git-send-email-pmladek@suse.com>

On Fri, Oct 20, 2017 at 04:56:51PM +0200, Petr Mladek wrote:
> __klp_disable_patch() should never be called when the patch is not
> enabled. Let's add the same warning that we have in __klp_enable_patch().
> 
> This allows to remove the check when calling klp_pre_unpatch_callback().
> It was strange anyway because it repeatedly checked per-patch flag
> for each patched object.
> 
> Signed-off-by: Petr Mladek <pmladek@suse.com>
> ---
>  kernel/livepatch/core.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
> index eb134479c394..287f71e9dbfe 100644
> --- a/kernel/livepatch/core.c
> +++ b/kernel/livepatch/core.c
> @@ -282,6 +282,9 @@ static int __klp_disable_patch(struct klp_patch *patch)
>  {
>  	struct klp_object *obj;
>  
> +	if (WARN_ON(!patch->enabled))
> +		return -EINVAL;
> +
>  	if (klp_transition_patch)
>  		return -EBUSY;
>  
> @@ -293,7 +296,7 @@ static int __klp_disable_patch(struct klp_patch *patch)
>  	klp_init_transition(patch, KLP_UNPATCHED);
>  
>  	klp_for_each_object(patch, obj)
> -		if (patch->enabled && obj->patched)
> +		if (obj->patched)
>  			klp_pre_unpatch_callback(obj);
>  
>  	/*
> -- 
> 1.8.5.6

Looks reasonable to me and cleans up the klp_pre_unpatch_callback()
calling condition.

Acked-by: Joe Lawrence <joe.lawrence@redhat.com>

  reply	other threads:[~2017-10-24 14:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 14:56 [PATCH 0/2] livepatch: Additional fixes for callbacks feature Petr Mladek
2017-10-20 14:56 ` [PATCH 1/2] livepatch: Correctly call klp_post_unpatch_callback() in error paths Petr Mladek
2017-10-24 18:33   ` Joe Lawrence
2017-10-20 14:56 ` [PATCH 2/2] livepatch: __klp_disable_patch() should never be called for disabled patches Petr Mladek
2017-10-24 14:27   ` Joe Lawrence [this message]
2017-11-01 10:10   ` Miroslav Benes
2017-10-26 12:59 ` [PATCH 0/2] livepatch: Additional fixes for callbacks feature Jiri Kosina

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=20171024142723.l5e7v2f7ckrlkbrc@redhat.com \
    --to=joe.lawrence@redhat.com \
    --cc=chris.j.arges@canonical.com \
    --cc=jeyu@kernel.org \
    --cc=jikos@kernel.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=pmladek@suse.com \
    /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

Powered by JetHome