Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3223793imu; Sat, 24 Nov 2018 00:29:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wed2Q0lHFyrFt2r3FsNrWuh+9M458itT0Cddrmz26sH6QeL4egoXf4tkGho0urVOjW6Qez X-Received: by 2002:a63:6f0d:: with SMTP id k13mr16956833pgc.42.1543048186652; Sat, 24 Nov 2018 00:29:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543048186; cv=none; d=google.com; s=arc-20160816; b=xTxAOn9qC98XlYm5V1uA9xChllYn74NJDxwJq4T+hd+SOdIzmTILLGx9aJkefI+LuY IWEk0vcaZZy0aum7xFIqpqAu4L1abLjLwr5c/ypUvEmHVg8TXU42gtvO/paxDKxblFo9 d/3Fke4PwH9Hx7tw36+PaKRxOj70eaGx82h3mvScySXitLurolaeRstmqZkmE97DgEYe EDq7T0d4Cux2LZF+5FFEFSg7VUQZ0yFn6yDOWdYIlBoUZcaaujIsQyfu4KnL97esIj6W s25ClD9AWRMNQLqDMhJQFAp7BApOTaP0i2tjBSBLSMw6UgwzgvIGYhiJC6mrIJFqzMkY kmBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=9bkqdKJkQXHo1taMltKWxzXoNU//7ubQgcBWXzWUlXg=; b=e7GV59KLDBq7KS9plhBMzcwUn9IIZS7icaKGIuE3yJ2itPcTcA2m4j5UmNf2h31TyY KMMjC7Eh1BZuxE6Stre7+lyGqoFDeLLok2WS+Y1mbgtU+oQKVWeBxrxwVbgLTPI305LM SiYOnBSjeMSTxQ8gh6w21NM025QY9shxX2h/1eZTKygJmvz1b3RsKQkaJDSQwmf78huP XfMuk0HWd8uxi93b97g8GEMju7uuzXNNeKq4JS9Hzd+fs40DtgOk7K/TlDprSKoA0CKq kjDfG2e1doE2DGcV5DP6ai1X4aL5Y8AvrIwdsWq9ar7K+aJZieB/XMy0M7l7/IWs//wa KXQg== 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 c1si12300985plz.121.2018.11.24.00.29.31; Sat, 24 Nov 2018 00:29:46 -0800 (PST) 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 S2409722AbeKWWoe (ORCPT + 99 others); Fri, 23 Nov 2018 17:44:34 -0500 Received: from mx2.suse.de ([195.135.220.15]:59408 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390446AbeKWWoe (ORCPT ); Fri, 23 Nov 2018 17:44:34 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2C182AE98; Fri, 23 Nov 2018 12:00:36 +0000 (UTC) Date: Fri, 23 Nov 2018 13:00:35 +0100 (CET) From: Miroslav Benes To: Petr Mladek cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: Re: [PATCH v13 08/12] livepatch: Add atomic replace In-Reply-To: <20181015123713.25868-9-pmladek@suse.com> Message-ID: References: <20181015123713.25868-1-pmladek@suse.com> <20181015123713.25868-9-pmladek@suse.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Oct 2018, Petr Mladek wrote: > +static int klp_add_object_nops(struct klp_patch *patch, > + struct klp_object *old_obj) > +{ > + struct klp_object *obj; > + struct klp_func *func, *old_func; > + > + obj = klp_find_object(patch, old_obj); > + > + if (!obj) { > + obj = klp_alloc_object_dynamic(old_obj->name); > + if (!obj) > + return -ENOMEM; > + > + list_add(&obj->node, &patch->obj_list); > + } > + > + klp_for_each_func(old_obj, old_func) { > + func = klp_find_func(obj, old_func); > + if (func) > + continue; > + > + func = klp_alloc_func_nop(old_func, obj); > + if (!func) > + return -ENOMEM; > + > + list_add(&func->node, &obj->func_list); > + } > + > + return 0; > +} Maybe you should consider list_add_tail() here too. > + > +/* > + * Add 'nop' functions which simply return to the caller to run > + * the original function. The 'nop' functions are added to a > + * patch to facilitate a 'replace' mode. > + */ > +static int klp_add_nops(struct klp_patch *patch) > +{ > + struct klp_patch *old_patch; > + struct klp_object *old_obj; > + int err = 0; The initialization is unnecessary. > + list_for_each_entry(old_patch, &klp_patches, list) { > + klp_for_each_object(old_patch, old_obj) { > + err = klp_add_object_nops(patch, old_obj); > + if (err) > + return err; > + } > + } > + > + return 0; > +} Miroslav