mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
	Joe Lawrence <joe.lawrence@redhat.com>,
	Jessica Yu <jeyu@kernel.org>, Nicolai Stange <nstange@suse.de>,
	live-patching@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] livepatch: Initialize shadow variables safely by a custom callback
Date: Fri, 6 Apr 2018 17:34:20 -0500	[thread overview]
Message-ID: <20180406223420.icjwcq7vy24tvecu@treble> (raw)
In-Reply-To: <20180405122315.29065-2-pmladek@suse.com>

On Thu, Apr 05, 2018 at 02:23:14PM +0200, Petr Mladek wrote:
> @@ -150,6 +149,23 @@ static void *__klp_shadow_get_or_alloc(void *obj, unsigned long id, void *data,
>  		goto exists;
>  	}
>  
> +	new_shadow->obj = obj;
> +	new_shadow->id = id;
> +
> +	if (ctor) {
> +		int err;
> +
> +		err = ctor(obj, new_shadow->data, ctor_data);
> +		if (err) {
> +			spin_unlock_irqrestore(&klp_shadow_lock, flags);
> +			kfree(new_shadow);
> +			WARN(1,
> +			     "Failed to construct shadow variable <%p, %lx>\n",
> +			     obj, id);
> +			return NULL;
> +		}
> +	}
> +

I'm not sure why a constructor would return an error, though I guess it
doesn't hurt to allow it.

The WARN seems excessive though, IMO.  The constructor itself can warn
(or printk or whatever else) if it thinks its warranted.

Also I think the 'err' variable isn't really needed.

-- 
Josh

  reply	other threads:[~2018-04-06 22:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05 12:23 [PATCH v2 0/2] livepatch: Allocate and free shadow variables more safely Petr Mladek
2018-04-05 12:23 ` [PATCH v2 1/2] livepatch: Initialize shadow variables safely by a custom callback Petr Mladek
2018-04-06 22:34   ` Josh Poimboeuf [this message]
2018-04-10 11:33     ` Petr Mladek
2018-04-11  9:29   ` Miroslav Benes
2018-04-05 12:23 ` [PATCH v2 2/2] livepatch: Allow to call a custom callback when freeing shadow variables Petr Mladek

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=20180406223420.icjwcq7vy24tvecu@treble \
    --to=jpoimboe@redhat.com \
    --cc=jeyu@kernel.org \
    --cc=jikos@kernel.org \
    --cc=joe.lawrence@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mbenes@suse.cz \
    --cc=nstange@suse.de \
    --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

all inboxes | Powered by JetHome®