Re: [PATCH] soc: qcom: rpmh: Avoid accessing freed memory from batch API

From: Stephen Boyd
Date: Tue Jan 08 2019 - 13:35:22 EST


Quoting Lina Iyer (2019-01-07 13:23:21)
> On Fri, Jan 04 2019 at 14:02 -0700, Evan Green wrote:
> >On Thu, Jan 3, 2019 at 9:47 AM Stephen Boyd <swboyd@xxxxxxxxxxxx> wrote:
> >>
> >> @@ -380,7 +386,10 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
> >> }
> >>
> >> for (i = 0; i < count; i++) {
> >> - rpm_msgs[i].completion = &compl;
> >> + struct completion *compl = &compls[i];
> >> +
> >> + init_completion(compl);
> >> + rpm_msgs[i].completion = compl;
> >> ret = rpmh_rsc_send_data(ctrlr_to_drv(ctrlr), &rpm_msgs[i].msg);
> >> if (ret) {
> >> pr_err("Error(%d) sending RPMH message addr=%#x\n",
> >
> >It's a little weird that we call rpmh_tx_done on a bunch of transfers
> >we never submitted, just so the completion will get signaled so we can
> >wait on it in the next loop. We could just do count = i; break; here
> >instead.
> >
> It seems like it was carried over from my earlier submissions, where I
> was reference counting the number of completions for a batch. I beleive,
> with what we are doing here, we don't need to call tx_done with this
> approach.

Ok. So we can remove this whole chunk of code that forces out
completions and unwind more properly?