Fix the way the create endpoint function returns the address number when RPMSG_ADDR_A...
authorMichal Princ (NXA17570) <michal.princ@nxp.com>
Thu, 18 Feb 2016 07:12:08 +0000 (08:12 +0100)
committerWendy Liang <jliang@xilinx.com>
Thu, 18 Feb 2016 21:26:15 +0000 (13:26 -0800)
This bug has been revealed when performing following steps:
1. create one endpoint with address RPMSG_ADDR_ANY.
2. get the address of that endpoint after it is created successfully.
3. use that address to create another endpoint.
It should not create the second endpoint with address of the first endpoint but somehow both endpoints were created successfully.

Restrict the endpoint address - zero address can't be assigned (due to the conflict in Linux world)

Signed-off-by: Michal Princ (NXA17570) <michal.princ@nxp.com>
lib/rpmsg/remote_device.c
lib/rpmsg/rpmsg_core.c

index 8134a8da94ddcd1c2dd51d39a4ec66b666e3dab0..e302c9ea985ccfddd2e08c60037ec7a9fc00a859 100644 (file)
@@ -128,6 +128,9 @@ int rpmsg_rdev_init(struct remote_device **rdev, int dev_id, int role,
        rdev_loc->channel_destroyed = channel_destroyed;
        rdev_loc->default_cb = default_cb;
 
+       /* Restrict the ept address - zero address can't be assigned */
+       rdev_loc->bitmap[0] = 1;
+
        /* Initialize the virtio device */
        virt_dev = &rdev_loc->virt_dev;
        virt_dev->device = proc;
index baeea82aea45ef798ff7b02e4e2d3d208350159b..226c28bfbf0045de816e54a1559f089b5b6563dd 100644 (file)
@@ -709,7 +709,7 @@ int rpmsg_get_address(unsigned long *bitmap, int size)
                tmp32 = get_first_zero_bit(bitmap[i]);
 
                if (tmp32 < 32) {
-                       addr = tmp32 + i + 1;
+                       addr = tmp32 + (i*32);
                        bitmap[i] |= (1 << tmp32);
                        break;
                }