Skip to content

Commit

Permalink
Merge tag 'rpmsg-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/remoteproc/linux

Pull rpmsg updates from Bjorn Andersson:
 "This contains fixes and cleanups in the rpmsg core, Qualcomm SMD and
  GLINK drivers, a circular lock dependency in the Mediatek driver and
  a possible race condition in the rpmsg_char driver is resolved"

* tag 'rpmsg-v5.20' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux:
  rpmsg: convert sysfs snprintf to sysfs_emit
  rpmsg: qcom_smd: Fix refcount leak in qcom_smd_parse_edge
  rpmsg: qcom: correct kerneldoc
  rpmsg: qcom: glink: remove unused name
  rpmsg: qcom: glink: replace strncpy() with strscpy_pad()
  rpmsg: Strcpy is not safe, use strscpy_pad() instead
  rpmsg: Fix possible refcount leak in rpmsg_register_device_override()
  rpmsg: Fix parameter naming for announce_create/destroy ops
  rpmsg: mtk_rpmsg: Fix circular locking dependency
  rpmsg: char: Add mutex protection for rpmsg_eptdev_open()
  • Loading branch information
Linus Torvalds committed Aug 8, 2022
2 parents e6cc0b5 + 7113ac8 commit c726876
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions drivers/rpmsg/mtk_rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ static void mtk_register_device_work_function(struct work_struct *register_work)
if (info->registered)
continue;

mutex_unlock(&subdev->channels_lock);
ret = mtk_rpmsg_register_device(subdev, &info->info);
mutex_lock(&subdev->channels_lock);
if (ret) {
dev_err(&pdev->dev, "Can't create rpmsg_device\n");
continue;
Expand Down
10 changes: 2 additions & 8 deletions drivers/rpmsg/qcom_glink_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ struct glink_core_rx_intent {
struct qcom_glink {
struct device *dev;

const char *name;

struct mbox_client mbox_client;
struct mbox_chan *mbox_chan;

Expand Down Expand Up @@ -1546,7 +1544,7 @@ static void qcom_glink_rx_close(struct qcom_glink *glink, unsigned int rcid)
cancel_work_sync(&channel->intent_work);

if (channel->rpdev) {
strncpy(chinfo.name, channel->name, sizeof(chinfo.name));
strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name));
chinfo.src = RPMSG_ADDR_ANY;
chinfo.dst = RPMSG_ADDR_ANY;

Expand Down Expand Up @@ -1674,7 +1672,7 @@ static ssize_t rpmsg_name_show(struct device *dev,
if (ret < 0)
name = dev->of_node->name;

return snprintf(buf, RPMSG_NAME_SIZE, "%s\n", name);
return sysfs_emit(buf, "%s\n", name);
}
static DEVICE_ATTR_RO(rpmsg_name);

Expand Down Expand Up @@ -1755,10 +1753,6 @@ struct qcom_glink *qcom_glink_native_probe(struct device *dev,
if (ret)
dev_err(dev, "failed to add groups\n");

ret = of_property_read_string(dev->of_node, "label", &glink->name);
if (ret < 0)
glink->name = dev->of_node->name;

glink->mbox_client.dev = dev;
glink->mbox_client.knows_txdone = true;
glink->mbox_chan = mbox_request_channel(&glink->mbox_client, 0);
Expand Down
2 changes: 1 addition & 1 deletion drivers/rpmsg/qcom_glink_ssr.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct cleanup_done_msg {
__le32 seq_num;
};

/**
/*
* G-Link SSR protocol commands
*/
#define GLINK_SSR_DO_CLEANUP 0
Expand Down
9 changes: 5 additions & 4 deletions drivers/rpmsg/qcom_smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,11 @@ static int qcom_smd_write_fifo(struct qcom_smd_channel *channel,
}

/**
* qcom_smd_send - write data to smd channel
* __qcom_smd_send - write data to smd channel
* @channel: channel handle
* @data: buffer of data to write
* @len: number of bytes to write
* @wait: flag to indicate if write has ca wait
* @wait: flag to indicate if write can wait
*
* This is a blocking write of len bytes into the channel's tx ring buffer and
* signal the remote end. It will sleep until there is enough space available
Expand Down Expand Up @@ -1089,7 +1089,7 @@ static int qcom_smd_create_device(struct qcom_smd_channel *channel)

/* Assign public information to the rpmsg_device */
rpdev = &qsdev->rpdev;
strncpy(rpdev->id.name, channel->name, RPMSG_NAME_SIZE);
strscpy_pad(rpdev->id.name, channel->name, RPMSG_NAME_SIZE);
rpdev->src = RPMSG_ADDR_ANY;
rpdev->dst = RPMSG_ADDR_ANY;

Expand Down Expand Up @@ -1323,7 +1323,7 @@ static void qcom_channel_state_worker(struct work_struct *work)

spin_unlock_irqrestore(&edge->channels_lock, flags);

strncpy(chinfo.name, channel->name, sizeof(chinfo.name));
strscpy_pad(chinfo.name, channel->name, sizeof(chinfo.name));
chinfo.src = RPMSG_ADDR_ANY;
chinfo.dst = RPMSG_ADDR_ANY;
rpmsg_unregister_device(&edge->dev, &chinfo);
Expand Down Expand Up @@ -1383,6 +1383,7 @@ static int qcom_smd_parse_edge(struct device *dev,
}

edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
of_node_put(syscon_np);
if (IS_ERR(edge->ipc_regmap)) {
ret = PTR_ERR(edge->ipc_regmap);
goto put_node;
Expand Down
7 changes: 6 additions & 1 deletion drivers/rpmsg/rpmsg_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,11 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)
struct rpmsg_device *rpdev = eptdev->rpdev;
struct device *dev = &eptdev->dev;

if (eptdev->ept)
mutex_lock(&eptdev->ept_lock);
if (eptdev->ept) {
mutex_unlock(&eptdev->ept_lock);
return -EBUSY;
}

get_device(dev);

Expand All @@ -137,11 +140,13 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)
if (!ept) {
dev_err(dev, "failed to open %s\n", eptdev->chinfo.name);
put_device(dev);
mutex_unlock(&eptdev->ept_lock);
return -EINVAL;
}

eptdev->ept = ept;
filp->private_data = eptdev;
mutex_unlock(&eptdev->ept_lock);

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/rpmsg/rpmsg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ int rpmsg_register_device_override(struct rpmsg_device *rpdev,
int ret;

if (driver_override)
strcpy(rpdev->id.name, driver_override);
strscpy_pad(rpdev->id.name, driver_override, RPMSG_NAME_SIZE);

dev_set_name(dev, "%s.%s.%d.%d", dev_name(dev->parent),
rpdev->id.name, rpdev->src, rpdev->dst);
Expand All @@ -618,6 +618,7 @@ int rpmsg_register_device_override(struct rpmsg_device *rpdev,
strlen(driver_override));
if (ret) {
dev_err(dev, "device_set_override failed: %d\n", ret);
put_device(dev);
return ret;
}
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/rpmsg/rpmsg_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ struct rpmsg_device_ops {
rpmsg_rx_cb_t cb, void *priv,
struct rpmsg_channel_info chinfo);

int (*announce_create)(struct rpmsg_device *ept);
int (*announce_destroy)(struct rpmsg_device *ept);
int (*announce_create)(struct rpmsg_device *rpdev);
int (*announce_destroy)(struct rpmsg_device *rpdev);
};

/**
Expand Down

0 comments on commit c726876

Please sign in to comment.