From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932252AbdJXO11 (ORCPT ); Tue, 24 Oct 2017 10:27:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33024 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932192AbdJXO1Z (ORCPT ); Tue, 24 Oct 2017 10:27:25 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8B920272D6 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=joe.lawrence@redhat.com Date: Tue, 24 Oct 2017 10:27:23 -0400 From: Joe Lawrence To: Petr Mladek Cc: Jiri Kosina , Josh Poimboeuf , Jessica Yu , Miroslav Benes , Chris J Arges , 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 Message-ID: <20171024142723.l5e7v2f7ckrlkbrc@redhat.com> References: <1508511411-4189-1-git-send-email-pmladek@suse.com> <1508511411-4189-3-git-send-email-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1508511411-4189-3-git-send-email-pmladek@suse.com> User-Agent: Mutt/1.6.2-neo (2016-08-08) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 24 Oct 2017 14:27:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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