From: Bjorn Andersson Date: Fri, 5 Jan 2018 23:58:00 +0000 (-0800) Subject: remoteproc: Clone rproc_ops in rproc_alloc() X-Git-Tag: v4.19~1642^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fb98e2bdbd5f5949459dcfe9976bdafdb0ed1948;p=platform%2Fkernel%2Flinux-rpi.git remoteproc: Clone rproc_ops in rproc_alloc() 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. Reviewed-By: Loic Pallardy Tested-By: Loic Pallardy Signed-off-by: Bjorn Andersson --- diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 208ccf7..dbf685db 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 6fdc62e..cc4d30a 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;