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: 10111031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1935160352 for ; Wed, 13 Dec 2017 22:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D82428AAC for ; Wed, 13 Dec 2017 22:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01F2328F75; Wed, 13 Dec 2017 22:42:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C17D28AAC for ; Wed, 13 Dec 2017 22:42:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751916AbdLMWmk (ORCPT ); Wed, 13 Dec 2017 17:42:40 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36482 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752807AbdLMWlU (ORCPT ); Wed, 13 Dec 2017 17:41:20 -0500 Received: by mail-pf0-f194.google.com with SMTP id p84so2198878pfd.3 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=rqfVUYAFPbHKtDf90Gv9EIphu6WgcXg1qyvfM34I/vZJdQlaLC7FeVJDuEiccTrAL5 DjhraYaVVoWmC/CnCBX/f5lKzTLRhD0W/V2+kyaNEIEA95aKTeTJJxZbMvJ1qo5VpGwu TjJqAMs2Skd4p4d9YaiVmC/Lqk7SBf2ksR+pMRL/QcShEMG/sGUY4gYTpynz0wbUpT6V QZWg85HcBjCEoCeqUbE8mqp6roIONRS6h/1UAnGU/nmflrrT1OFg0uwRCGHhMD4cIn1n rs2aq/6dnRdPfF8f2drRvwGyrgmrQurrn1Am9xsComfJe3qBIzSglU4yzbxWrKqjuoQv lO6g== X-Gm-Message-State: AKGB3mIWb3uXN1MfkvLB2bvCBCyJHmOAIqwpbHIP3eKk7yxZVgmS5qI+ rBmFGmrHuuJFNLjCnUysvXQRow== X-Google-Smtp-Source: ACJfBotewn8I5PTtLLny1nNTb1wpXHK3bLxR0m1EN9AGqWnPSYXwYUTzOiQpfMbjLc6Mroek0tJHDA== 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-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;