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>
This commit is contained in:
parent
345c8bec42
commit
e8184e6c2d
3 changed files with 24 additions and 68 deletions
|
@ -40,27 +40,6 @@
|
||||||
*/
|
*/
|
||||||
extern int cfg_get_cd_version(u32 *version);
|
extern int cfg_get_cd_version(u32 *version);
|
||||||
|
|
||||||
/*
|
|
||||||
* ======== cfg_get_dev_object ========
|
|
||||||
* Purpose:
|
|
||||||
* Retrieve the Device Object handle for a given devnode.
|
|
||||||
* Parameters:
|
|
||||||
* dev_node_obj: Platform's dev_node handle from which to retrieve
|
|
||||||
* value.
|
|
||||||
* value: Ptr to location to store the value.
|
|
||||||
* Returns:
|
|
||||||
* 0: Success.
|
|
||||||
* -EFAULT: dev_node_obj is invalid or device_obj is invalid.
|
|
||||||
* -ENODATA: The resource is not available.
|
|
||||||
* Requires:
|
|
||||||
* CFG initialized.
|
|
||||||
* Ensures:
|
|
||||||
* 0: *value is set to the retrieved u32.
|
|
||||||
* else: *value is set to 0L.
|
|
||||||
*/
|
|
||||||
extern int cfg_get_dev_object(struct cfg_devnode *dev_node_obj,
|
|
||||||
u32 *value);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ======== cfg_get_exec_file ========
|
* ======== cfg_get_exec_file ========
|
||||||
* Purpose:
|
* Purpose:
|
||||||
|
|
|
@ -85,6 +85,11 @@ struct dev_object {
|
||||||
struct node_mgr *hnode_mgr;
|
struct node_mgr *hnode_mgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct drv_ext {
|
||||||
|
struct list_head link;
|
||||||
|
char sz_string[MAXREGPATHLENGTH];
|
||||||
|
};
|
||||||
|
|
||||||
/* ----------------------------------- Globals */
|
/* ----------------------------------- Globals */
|
||||||
static u32 refs; /* Module reference count */
|
static u32 refs; /* Module reference count */
|
||||||
|
|
||||||
|
@ -812,18 +817,31 @@ int dev_remove_device(struct cfg_devnode *dev_node_obj)
|
||||||
{
|
{
|
||||||
struct dev_object *hdev_obj; /* handle to device object */
|
struct dev_object *hdev_obj; /* handle to device object */
|
||||||
int status = 0;
|
int status = 0;
|
||||||
struct dev_object *dev_obj;
|
struct drv_data *drv_datap = dev_get_drvdata(bridge);
|
||||||
|
|
||||||
|
if (!drv_datap)
|
||||||
|
status = -ENODATA;
|
||||||
|
|
||||||
|
if (!dev_node_obj)
|
||||||
|
status = -EFAULT;
|
||||||
|
|
||||||
/* Retrieve the device object handle originaly stored with
|
/* Retrieve the device object handle originaly stored with
|
||||||
* the dev_node: */
|
* the dev_node: */
|
||||||
status = cfg_get_dev_object(dev_node_obj, (u32 *) &hdev_obj);
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* Remove the Processor List */
|
/* check the device string and then store dev object */
|
||||||
dev_obj = (struct dev_object *)hdev_obj;
|
if (!strcmp((char *)((struct drv_ext *)dev_node_obj)->sz_string,
|
||||||
/* Destroy the device object. */
|
"TIOMAP1510")) {
|
||||||
status = dev_destroy_device(hdev_obj);
|
hdev_obj = drv_datap->dev_object;
|
||||||
|
/* Destroy the device object. */
|
||||||
|
status = dev_destroy_device(hdev_obj);
|
||||||
|
} else {
|
||||||
|
status = -EPERM;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (status)
|
||||||
|
pr_err("%s: Failed, status 0x%x\n", __func__, status);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,47 +30,6 @@
|
||||||
#include <dspbridge/cfg.h>
|
#include <dspbridge/cfg.h>
|
||||||
#include <dspbridge/drv.h>
|
#include <dspbridge/drv.h>
|
||||||
|
|
||||||
struct drv_ext {
|
|
||||||
struct list_head link;
|
|
||||||
char sz_string[MAXREGPATHLENGTH];
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ======== cfg_get_dev_object ========
|
|
||||||
* Purpose:
|
|
||||||
* Retrieve the Device Object handle for a given devnode.
|
|
||||||
*/
|
|
||||||
int cfg_get_dev_object(struct cfg_devnode *dev_node_obj,
|
|
||||||
u32 *value)
|
|
||||||
{
|
|
||||||
int status = 0;
|
|
||||||
u32 dw_buf_size;
|
|
||||||
struct drv_data *drv_datap = dev_get_drvdata(bridge);
|
|
||||||
|
|
||||||
if (!drv_datap)
|
|
||||||
status = -EPERM;
|
|
||||||
|
|
||||||
if (!dev_node_obj)
|
|
||||||
status = -EFAULT;
|
|
||||||
|
|
||||||
if (!value)
|
|
||||||
status = -EFAULT;
|
|
||||||
|
|
||||||
dw_buf_size = sizeof(value);
|
|
||||||
if (!status) {
|
|
||||||
|
|
||||||
/* check the device string and then store dev object */
|
|
||||||
if (!
|
|
||||||
(strcmp
|
|
||||||
((char *)((struct drv_ext *)dev_node_obj)->sz_string,
|
|
||||||
"TIOMAP1510")))
|
|
||||||
*value = (u32)drv_datap->dev_object;
|
|
||||||
}
|
|
||||||
if (status)
|
|
||||||
pr_err("%s: Failed, status 0x%x\n", __func__, status);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ======== cfg_get_exec_file ========
|
* ======== cfg_get_exec_file ========
|
||||||
* Purpose:
|
* Purpose:
|
||||||
|
|
Loading…
Add table
Reference in a new issue