Received: by 10.213.65.68 with SMTP id h4csp3773620imn; Tue, 10 Apr 2018 04:36:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Pyv4Q7cfl8fbhc1KIiEU6UEug2SUGLFy8TuPxAST8KJ7ubJzBApBn4dROaUFdr2TIF8jR X-Received: by 2002:a17:902:a24:: with SMTP id 33-v6mr54523plo.72.1523360207745; Tue, 10 Apr 2018 04:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523360207; cv=none; d=google.com; s=arc-20160816; b=WKB7ksV/55JIVxzjt7pjQW5hMoIXA9XThgfureQmFX0IEiyNgPJzYFEKTLW35JE+uX 1BNJEdRDRLpAv3mX4D7X4pTHPC+Z1uLUWPwG87YtDfU/QldujhHxk5L4CupkRLRHyo8z Yjmd9t+aM3fR2wRpu6UnKezCB3irAFucsL//1ouhEPToeCsDDGw0g+pEFTg8z1WcO033 dI5ZjGmrU3WE6KyR3cyAgBHyvot3dVpQIU35aKdc8DaMAEceh6RlixNO7pRVb0fa5hYB MruaUmeziEs09IUF53ifw+Guz/W0taEkTQmmJdV7PswpBgyqtTTssTz5nhEhANbT+7GD 4nsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=yjnTTovs8j90u9nvNMROwHCrD02T6FzAxhmXzPt4jTY=; b=grRSBZPtdeo0J2r6TmoGY+lE2fhuXG0bOfVlybyJtdQt6FOjCY4RW0CkW5tj0AgZYf 6s/5D0wyPPqCR51rW08hVicOx7X1nZa1SLguK6yjI//udf0B0wW+MylNUj2vRMasGUeM UJCiPKTTsVvPbVP9ErYxObi22axK0bSzcXYLwJ+Ex7kMIzRI+TcmCDfLMILwwDk+4NHZ ZYZnhu2L8AsvoYWYSXAuBWZVb8pAnjTEyADdPFJ9nW3Oebuo9USjhoOpxH1P0QtL3y/F HVTyA5E804r2vzpcH5IwMRHoPopGHRsFZc1NzXTstJW3ipfHpN0ZITy/rjsLOFq2xsbK 0UBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j26si1900260pfh.266.2018.04.10.04.36.10; Tue, 10 Apr 2018 04:36:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbeDJLdW (ORCPT + 99 others); Tue, 10 Apr 2018 07:33:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:35182 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404AbeDJLdV (ORCPT ); Tue, 10 Apr 2018 07:33:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CB8F2AF80; Tue, 10 Apr 2018 11:33:19 +0000 (UTC) Date: Tue, 10 Apr 2018 13:33:19 +0200 From: Petr Mladek To: Josh Poimboeuf Cc: Jiri Kosina , Miroslav Benes , Joe Lawrence , Jessica Yu , Nicolai Stange , 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 Message-ID: <20180410113319.wgopcxznq7pqpxi7@pathway.suse.cz> References: <20180405122315.29065-1-pmladek@suse.com> <20180405122315.29065-2-pmladek@suse.com> <20180406223420.icjwcq7vy24tvecu@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180406223420.icjwcq7vy24tvecu@treble> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 2018-04-06 17:34:20, Josh Poimboeuf wrote: > 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. It is true that constructors usually do not return an error code, namely C++ or Java. But it is not true that they could not fail. These languages use exceptions instead. IMHO, the return value makes sense here. > The WARN seems excessive though, IMO. The constructor itself can warn > (or printk or whatever else) if it thinks its warranted. I am just fascinated by WARN(). But you are right. I am going to replace it with pr_err("Failed to construct shadow variable <%p, %lx> (%d)\n", obj, id, err); > Also I think the 'err' variable isn't really needed. Yup. Well, it will be needed by the pr_err() ;-) Best Regard, Petr