[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAF6AEGs+yfLHzFag4dMNiBxO7fcVQFSP+4n8zdfttwXpeS+X5w@mail.gmail.com>
Date: Fri, 18 Mar 2022 08:06:57 -0700
From: Rob Clark <robdclark@...il.com>
To: Dan Carpenter <dan.carpenter@...cle.com>
Cc: dri-devel <dri-devel@...ts.freedesktop.org>,
freedreno <freedreno@...ts.freedesktop.org>,
linux-arm-msm <linux-arm-msm@...r.kernel.org>,
Rob Clark <robdclark@...omium.org>,
Sean Paul <sean@...rly.run>,
Abhinav Kumar <quic_abhinavk@...cinc.com>,
David Airlie <airlied@...ux.ie>,
Daniel Vetter <daniel@...ll.ch>,
Akhil P Oommen <quic_akhilpo@...cinc.com>,
Jonathan Marek <jonathan@...ek.ca>,
Jordan Crouse <jordan@...micpenguin.net>,
Emma Anholt <emma@...olt.net>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] drm/msm: Add a way to override processes comm/cmdline
On Fri, Mar 18, 2022 at 12:19 AM Dan Carpenter <dan.carpenter@...cle.com> wrote:
>
> On Thu, Mar 17, 2022 at 08:03:59AM -0700, Rob Clark wrote:
> > > > diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
> > > > index 4ec62b601adc..68f3f8ade76d 100644
> > > > --- a/drivers/gpu/drm/msm/msm_gpu.c
> > > > +++ b/drivers/gpu/drm/msm/msm_gpu.c
> > > > @@ -364,14 +364,21 @@ static void retire_submits(struct msm_gpu *gpu);
> > > >
> > > > static void get_comm_cmdline(struct msm_gem_submit *submit, char **comm, char **cmd)
> > > > {
> > > > + struct msm_file_private *ctx = submit->queue->ctx;
> > > > struct task_struct *task;
> > > >
> > > > + *comm = kstrdup(ctx->comm, GFP_KERNEL);
> > > > + *cmd = kstrdup(ctx->cmdline, GFP_KERNEL);
> > > > +
> > > > task = get_pid_task(submit->pid, PIDTYPE_PID);
> > > > if (!task)
> > > > return;
> > > >
> > > > - *comm = kstrdup(task->comm, GFP_KERNEL);
> > > > - *cmd = kstrdup_quotable_cmdline(task, GFP_KERNEL);
> > > > + if (!*comm)
> > > > + *comm = kstrdup(task->comm, GFP_KERNEL);
> > >
> > > What?
> > >
> > > If the first allocation failed, then this one is going to fail as well.
> > > Just return -ENOMEM. Or maybe this is meant to be checking for an empty
> > > string?
> >
> > fwiw, if ctx->comm is NULL, the kstrdup() will return NULL, so this
> > isn't intended to deal with OoM, but the case that comm and/or cmdline
> > is not overridden.
>
> Ah, I should have thought about that. Thanks!
np, I realized it was fairly non-obvious so I added a comment in v2 to
hopefully make it more clear
BR,
-R
> regards,
> dan carpenter
>
Powered by blists - more mailing lists