From patchwork Wed Dec 13 22:41:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 121871 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp6064624qgn; Wed, 13 Dec 2017 14:42:44 -0800 (PST) X-Google-Smtp-Source: ACJfBotcIaSQGp3crUiCNzke2Tkv9mPtgg3fAAuT+TcqoLudNShvn1QNXLi6iu66G44mBlASHiqd X-Received: by 10.159.214.138 with SMTP id n10mr7563562plp.362.1513204964371; Wed, 13 Dec 2017 14:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513204964; cv=none; d=google.com; s=arc-20160816; b=tO/qQyaQv6AjcUqblHie1yToTmZpe2T9BX9OcnTOODzOyL36TnDYpO62499DicfuNb 6Y5sDVs0LvFQkubtBrzn0DOzlP+KekQokTsG/HMQnQ3qnvZukOwDJUyKhY+WwfzJG5l1 YiDvLNgfsiFpMbrCS2meC5hFmiX1cIDIq8OGYeR+92LyFxmPQ890INJVh9YpoHqxJ7M2 RUXSXqLDNhmvWEeAhEHZRhmt7R+lJubY4c9vbE8IcdYV0SRWrg6zRoLLKuJVSdyXnf8r NZx6OQtunk6JoESMm9mjDJ9Zr3wdJ3qVp8PFQEPxtA9iAPFubULAQzwvBbf2thzAgJso xDVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=xhCBnesiLjhoYEEDZ5FhKfryaBuOCtv9nmTPhUeGhnk=; b=EBJCDv3se/y4gnmbitXo0QJ02KRlqfmnVh+Qc+WIcGh3FS/EhRc8Do9dItUCMlYTwN YKQvxZADtYX93JQxP9g9524v3IzjfeI+B3otG16BQiM40IpOgtLbQBSDwSf5owi93ziV iHBlqV3z2x/R+hNhiShV8WYewyrh8R3MyuWRRom9a9Vs/iGRRY9tOLo1wvO7IqnYkMlY Lws/f5stEkmBSctC06r3I9LalFVOaU3Rzb4HcHMmLXNs6Tk+jceZ4y/YN2yR1HcGCSak 0tN9qI4LjyGGAo6GOFXltV6WgqXmbTSEjCFg3s8geXbQ1YtT35wuLcmWuqow1lCtdIiw 5jwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LfAabWRX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t25si1877854pgv.644.2017.12.13.14.42.44; Wed, 13 Dec 2017 14:42:44 -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; dkim=pass header.i=@linaro.org header.s=google header.b=LfAabWRX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753187AbdLMWml (ORCPT + 23 others); Wed, 13 Dec 2017 17:42:41 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:44352 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752811AbdLMWlU (ORCPT ); Wed, 13 Dec 2017 17:41:20 -0500 Received: by mail-pf0-f195.google.com with SMTP id m26so2183611pfj.11 for ; Wed, 13 Dec 2017 14:41:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xhCBnesiLjhoYEEDZ5FhKfryaBuOCtv9nmTPhUeGhnk=; b=LfAabWRXEH9qPoYmSxSVs2YvALfcGI2YJpwEw/y0K5s/JipPPWaqqpUw0OT3bFPxtO cCb4nIMnP3vXQdgk9bWimyHFNKkvw2JhFblC9YFfdiiKGvI5/EqgVMdOYT+Y1s2Bm6kC f3YQpSZ0Ay+Sf3jzVATEHIT7YHQ5sBq1LOk6U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xhCBnesiLjhoYEEDZ5FhKfryaBuOCtv9nmTPhUeGhnk=; b=MvnVWvaYActig3JhD4yoOZjQ6mnnBWa+TB3EOBYp4GBynjBpMR4mpfSMsVjA6KynNA dojFWtXcu2YNL8Htc8mYYcBp9s64B5OO/0BiR5kexspWgS/oSEa+hoQRy1slBxgO6YUQ ncxbTFfVGhOur5JF0DxbjhuPgaLbKQdr8qjmQFyAo0xO/5dh77irZAoG9o4QANtmOcGy iWTDUqxnB7qHl/MDi/RqwFg+LO0lQ5SG18VI5DklOuG9WrKN8dZ+XW8uvN88jAQ5ct8f 2b9bufMnr7G2F7tyQ5wzmISVbpDwS/rGFeQVrs9rUbVIp2FDgNt1YzH0E2nOMlVv0bT0 RFvw== X-Gm-Message-State: AKGB3mJaMSv17Jwb5yogSylYis4O4nDOKS1TiosZeRaAY0bbZTcGNvhc PYNHmqIjYgcatx20cJOEEbe6LA== X-Received: by 10.98.76.90 with SMTP id z87mr7604905pfa.194.1513204879510; Wed, 13 Dec 2017 14:41:19 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id x15sm4464205pfh.27.2017.12.13.14.41.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 14:41:18 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] remoteproc: Clone rproc_ops in rproc_alloc() Date: Wed, 13 Dec 2017 14:41:06 -0800 Message-Id: <20171213224111.17864-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171213224111.17864-1-bjorn.andersson@linaro.org> References: <20171213224111.17864-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to allow rproc_alloc() to, in a future patch, update entries in the "ops" struct we need to make a local copy of it. Signed-off-by: Bjorn Andersson --- drivers/remoteproc/remoteproc_core.c | 9 ++++++++- include/linux/remoteproc.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 761268096fe0..9bc9ee8f4513 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1342,6 +1342,7 @@ static void rproc_type_release(struct device *dev) ida_simple_remove(&rproc_dev_index, rproc->index); kfree(rproc->firmware); + kfree(rproc->ops); kfree(rproc); } @@ -1406,9 +1407,15 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, return NULL; } + rproc->ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); + if (!rproc->ops) { + kfree(p); + kfree(rproc); + return NULL; + } + rproc->firmware = p; rproc->name = name; - rproc->ops = ops; rproc->priv = &rproc[1]; rproc->auto_boot = true; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index b72be13d773d..6cbc0379a926 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -419,7 +419,7 @@ struct rproc { const char *name; char *firmware; void *priv; - const struct rproc_ops *ops; + struct rproc_ops *ops; struct device dev; const struct rproc_fw_ops *fw_ops; atomic_t power;