diff options
author | Julia Lawall <julia@diku.dk> | 2010-10-15 15:00:10 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-15 12:44:25 -0700 |
commit | cc58cbb88569e3ecb9786b3da891e7d019d2cfff (patch) | |
tree | a9cf0bbafc40044f6e562d926f35b0b98adfd64e /drivers/staging | |
parent | aaf0885c30449d7b40d7cb5b07d6ff64b419c0d1 (diff) | |
download | linux-cc58cbb88569e3ecb9786b3da891e7d019d2cfff.tar.bz2 |
staging: tidspbridge: Clean up error-handling code
In the first hunk, 0 is returned on memory allocation failure, even though
other failures return -ENOMEM or other similar values.
In the second hunk, there was error handling code that returned without
freeing psz_path_name.
A simplified version of the semantic match that finds the first problem is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression ret;
expression x,e1,e2,e3;
@@
ret = 0
... when != ret = e1
*x = \(kmalloc\|kcalloc\|kzalloc\)(...)
... when != ret = e2
if (x == NULL) { ... when != ret = e3
return ret;
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/tidspbridge/pmgr/dspapi.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/staging/tidspbridge/pmgr/dspapi.c b/drivers/staging/tidspbridge/pmgr/dspapi.c index 0187c47fb4d8..981551ce4d78 100644 --- a/drivers/staging/tidspbridge/pmgr/dspapi.c +++ b/drivers/staging/tidspbridge/pmgr/dspapi.c @@ -493,8 +493,10 @@ u32 mgrwrap_register_object(union trapped_args *args, void *pr_ctxt) args->args_mgr_registerobject.psz_path_name) + 1; psz_path_name = kmalloc(path_size, GFP_KERNEL); - if (!psz_path_name) + if (!psz_path_name) { + status = -ENOMEM; goto func_end; + } ret = strncpy_from_user(psz_path_name, (char *)args->args_mgr_registerobject. psz_path_name, path_size); @@ -503,8 +505,10 @@ u32 mgrwrap_register_object(union trapped_args *args, void *pr_ctxt) goto func_end; } - if (args->args_mgr_registerobject.obj_type >= DSP_DCDMAXOBJTYPE) - return -EINVAL; + if (args->args_mgr_registerobject.obj_type >= DSP_DCDMAXOBJTYPE) { + status = -EINVAL; + goto func_end; + } status = dcd_register_object(&uuid_obj, args->args_mgr_registerobject.obj_type, |