[PATCH] cxl: Fix leaking pid refs in some error paths

Andrew Donnellan andrew.donnellan at au1.ibm.com
Fri Oct 21 17:19:05 AEDT 2016


On 21/10/16 16:46, Vaibhav Jain wrote:
> In some error paths in functions cxl_start_context and
> afu_ioctl_start_work pid references to the current & group-leader tasks
> can leak after they are taken. This patch fixes these error paths to
> release these pid references before exiting the error path.
>
> This patch is based on earlier patch "cxl: Prevent adapter reset
> if an active context exists" at
> https://patchwork.ozlabs.org/patch/682187/

Put this paragraph under the ---.

>
> Fixes: 7b8ad495("cxl: Fix DSI misses when the context owning task exits")
> Reported-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>
> Signed-off-by: Vaibhav Jain <vaibhav at linux.vnet.ibm.com>

Reviewed-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>

> ---
>  drivers/misc/cxl/api.c  |  2 ++
>  drivers/misc/cxl/file.c | 22 +++++++++++++---------
>  2 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
> index af23d7d..2e5233b 100644
> --- a/drivers/misc/cxl/api.c
> +++ b/drivers/misc/cxl/api.c
> @@ -247,7 +247,9 @@ int cxl_start_context(struct cxl_context *ctx, u64 wed,
>  	cxl_ctx_get();
>
>  	if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) {
> +		put_pid(ctx->glpid);
>  		put_pid(ctx->pid);
> +		ctx->glpid = ctx->pid = NULL;

This is only needed if task != NULL, but I think it should be okay as 
long as ctx->[gl]pid is already NULL in that situation (which I haven't 
checked but I think that's the case).

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com  IBM Australia Limited



More information about the Linuxppc-dev mailing list