Skip to content

Commit

Permalink
handle_vdev_rsc must return error if notifyid cannot be assigned
Browse files Browse the repository at this point in the history
Updated handle_vdev_rsc to return error if a unique id cannot be assigned
Signed-off-by: Tammy Leino <tammy_leino@mentor.com>
  • Loading branch information
tammyleino authored and arnopo committed Oct 4, 2022
1 parent e40eea8 commit 03c80a1
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/remoteproc/rsc_table_parser.c
Expand Up @@ -7,6 +7,7 @@
*/

#include <metal/io.h>
#include <metal/utilities.h>
#include <openamp/rsc_table_parser.h>

static int handle_dummy_rsc(struct remoteproc *rproc, void *rsc);
Expand Down Expand Up @@ -126,14 +127,18 @@ int handle_vendor_rsc(struct remoteproc *rproc, void *rsc)
int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
{
struct fw_rsc_vdev *vdev_rsc = rsc;
unsigned int notifyid, i, num_vrings;
int i, num_vrings;
unsigned int notifyid;
struct fw_rsc_vdev_vring *vring_rsc;

/* only assign notification IDs but do not initialize vdev */
notifyid = vdev_rsc->notifyid;
notifyid = remoteproc_allocate_id(rproc,
notifyid, notifyid + 1);
if (notifyid != RSC_NOTIFY_ID_ANY)
vdev_rsc->notifyid = notifyid;
else
return -RPROC_ERR_RSC_TAB_NP;

num_vrings = vdev_rsc->num_of_vrings;
for (i = 0; i < num_vrings; i++) {
Expand All @@ -146,9 +151,20 @@ int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
notifyid + 1);
if (notifyid != RSC_NOTIFY_ID_ANY)
vring_rsc->notifyid = notifyid;
else
goto err;
}

return 0;

err:
for (i--; i >= 0; i--) {
vring_rsc = &vdev_rsc->vring[i];
metal_bitmap_clear_bit(&rproc->bitmap, vring_rsc->notifyid);
}
metal_bitmap_clear_bit(&rproc->bitmap, vdev_rsc->notifyid);

return -RPROC_ERR_RSC_TAB_NP;
}

/**
Expand Down

0 comments on commit 03c80a1

Please sign in to comment.