From martyn.welch@gefanuc.com Thu Oct 29 16:13:51 2009 From: Martyn Welch Date: Thu, 29 Oct 2009 16:35:08 +0000 Subject: Staging: vme: Correct operation of vme_lm_free To: gregkh@suse.de Cc: devel@linuxdriverproject.org Message-ID: <20091029163508.18368.60364.stgit@ES-J7S4D2J.amer.consind.ge.com> The vme_lm_free() function is not clearing up the resource created in vme_lm_request(). In addition vme_lm_free() is void function and is used in exit/error paths, we should wait for mutex to become free rather than exiting and not freeing the resource. Signed-off-by: Martyn Welch Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vme/vme.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/drivers/staging/vme/vme.c +++ b/drivers/staging/vme/vme.c @@ -1191,7 +1191,7 @@ int vme_lm_set(struct vme_resource *reso /* XXX Check parameters */ - return lm->parent->lm_set(lm, lm_base, aspace, cycle); + return bridge->lm_set(lm, lm_base, aspace, cycle); } EXPORT_SYMBOL(vme_lm_set); @@ -1271,16 +1271,18 @@ void vme_lm_free(struct vme_resource *re lm = list_entry(resource->entry, struct vme_lm_resource, list); - if (mutex_trylock(&(lm->mtx))) { - printk(KERN_ERR "Resource busy, can't free\n"); - return; - } + mutex_lock(&(lm->mtx)); - /* XXX Check to see that there aren't any callbacks still attached */ + /* XXX + * Check to see that there aren't any callbacks still attached, if + * there are we should probably be detaching them! + */ lm->locked = 0; mutex_unlock(&(lm->mtx)); + + kfree(resource); } EXPORT_SYMBOL(vme_lm_free);