aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/tidspbridge/pmgr
diff options
context:
space:
mode:
authorIvan Gomez Castellanos <ivan.gomez@ti.com>2010-08-25 18:08:58 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-08-31 14:23:15 -0400
commite8184e6c2d32eb4418f6084155ac1ffb08c751e8 (patch)
treeb22a075c9f18ca95684161cc4bf049eb76cdf722 /drivers/staging/tidspbridge/pmgr
parent345c8bec42d7c55f98167da596ea5ca5f53d9f7d (diff)
staging: tidspbridge: Remove cfg_get_dev_object() and do a trivial cleanup
The cfg_get_dev_object function is only used in one place and because of its simplicity, it can be removed. The parameter *value can be left uninitialized if the strcmp() returns a nonzero value, so in the function dev_remove_device(), the hdev_obj could be used uninitialized and could be dereferenced in dev_destroy_device(). This patch fixes this issue, and also removes the dev_obj pointer which is not used. Signed-off-by: Ivan Gomez Castellanos <ivan.gomez@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/tidspbridge/pmgr')
-rw-r--r--drivers/staging/tidspbridge/pmgr/dev.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/drivers/staging/tidspbridge/pmgr/dev.c b/drivers/staging/tidspbridge/pmgr/dev.c
index 4ddf03d3b1a..7893f9a0cf0 100644
--- a/drivers/staging/tidspbridge/pmgr/dev.c
+++ b/drivers/staging/tidspbridge/pmgr/dev.c
@@ -85,6 +85,11 @@ struct dev_object {
85 struct node_mgr *hnode_mgr; 85 struct node_mgr *hnode_mgr;
86}; 86};
87 87
88struct drv_ext {
89 struct list_head link;
90 char sz_string[MAXREGPATHLENGTH];
91};
92
88/* ----------------------------------- Globals */ 93/* ----------------------------------- Globals */
89static u32 refs; /* Module reference count */ 94static u32 refs; /* Module reference count */
90 95
@@ -812,18 +817,31 @@ int dev_remove_device(struct cfg_devnode *dev_node_obj)
812{ 817{
813 struct dev_object *hdev_obj; /* handle to device object */ 818 struct dev_object *hdev_obj; /* handle to device object */
814 int status = 0; 819 int status = 0;
815 struct dev_object *dev_obj; 820 struct drv_data *drv_datap = dev_get_drvdata(bridge);
821
822 if (!drv_datap)
823 status = -ENODATA;
824
825 if (!dev_node_obj)
826 status = -EFAULT;
816 827
817 /* Retrieve the device object handle originaly stored with 828 /* Retrieve the device object handle originaly stored with
818 * the dev_node: */ 829 * the dev_node: */
819 status = cfg_get_dev_object(dev_node_obj, (u32 *) &hdev_obj);
820 if (!status) { 830 if (!status) {
821 /* Remove the Processor List */ 831 /* check the device string and then store dev object */
822 dev_obj = (struct dev_object *)hdev_obj; 832 if (!strcmp((char *)((struct drv_ext *)dev_node_obj)->sz_string,
823 /* Destroy the device object. */ 833 "TIOMAP1510")) {
824 status = dev_destroy_device(hdev_obj); 834 hdev_obj = drv_datap->dev_object;
835 /* Destroy the device object. */
836 status = dev_destroy_device(hdev_obj);
837 } else {
838 status = -EPERM;
839 }
825 } 840 }
826 841
842 if (status)
843 pr_err("%s: Failed, status 0x%x\n", __func__, status);
844
827 return status; 845 return status;
828} 846}
829 847