mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
rpmsg: smd: do not use mananged resources for endpoints and channels
All the managed resources would be freed by the time release function
is invoked. Handling such memory in qcom_smd_edge_release() would do
bad things.
Found this issue while testing Audio usecase where the dsp is started up
and shutdown in a loop.
This patch fixes this issue by using simple kzalloc for allocating
channel->name and channel which is then freed in qcom_smd_edge_release().
Without this patch restarting a remoteproc would crash the system.
Fixes: 53e2822e56
("rpmsg: Introduce Qualcomm SMD backend")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
parent
136200f4fd
commit
4a2e84c6ed
@ -1108,12 +1108,12 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
|
|||||||
void *info;
|
void *info;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
channel = devm_kzalloc(&edge->dev, sizeof(*channel), GFP_KERNEL);
|
channel = kzalloc(sizeof(*channel), GFP_KERNEL);
|
||||||
if (!channel)
|
if (!channel)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
channel->edge = edge;
|
channel->edge = edge;
|
||||||
channel->name = devm_kstrdup(&edge->dev, name, GFP_KERNEL);
|
channel->name = kstrdup(name, GFP_KERNEL);
|
||||||
if (!channel->name)
|
if (!channel->name)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
@ -1164,8 +1164,8 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
|
|||||||
return channel;
|
return channel;
|
||||||
|
|
||||||
free_name_and_channel:
|
free_name_and_channel:
|
||||||
devm_kfree(&edge->dev, channel->name);
|
kfree(channel->name);
|
||||||
devm_kfree(&edge->dev, channel);
|
kfree(channel);
|
||||||
|
|
||||||
return ERR_PTR(ret);
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
@ -1396,13 +1396,13 @@ static int qcom_smd_parse_edge(struct device *dev,
|
|||||||
*/
|
*/
|
||||||
static void qcom_smd_edge_release(struct device *dev)
|
static void qcom_smd_edge_release(struct device *dev)
|
||||||
{
|
{
|
||||||
struct qcom_smd_channel *channel;
|
struct qcom_smd_channel *channel, *tmp;
|
||||||
struct qcom_smd_edge *edge = to_smd_edge(dev);
|
struct qcom_smd_edge *edge = to_smd_edge(dev);
|
||||||
|
|
||||||
list_for_each_entry(channel, &edge->channels, list) {
|
list_for_each_entry_safe(channel, tmp, &edge->channels, list) {
|
||||||
SET_RX_CHANNEL_INFO(channel, state, SMD_CHANNEL_CLOSED);
|
list_del(&channel->list);
|
||||||
SET_RX_CHANNEL_INFO(channel, head, 0);
|
kfree(channel->name);
|
||||||
SET_RX_CHANNEL_INFO(channel, tail, 0);
|
kfree(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
kfree(edge);
|
kfree(edge);
|
||||||
|
Loading…
Reference in New Issue
Block a user