Commit 2b356b46 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Jeff Garzik

claw: fix memory leak in claw_probe.

probe_error() frees memory only, if cgdev->dev.driver_data refers
to the claw_privbk structure. Move forward its setting in claw_probe()
to ensure proper freeing of claw_privbk allocations.

Cc: Daniel <danielm77@spray.se>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent d3d7b53d
......@@ -271,6 +271,7 @@ claw_probe(struct ccwgroup_device *cgdev)
if (!get_device(&cgdev->dev))
return -ENODEV;
privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
cgdev->dev.driver_data = privptr;
if (privptr == NULL) {
probe_error(cgdev);
put_device(&cgdev->dev);
......@@ -305,7 +306,6 @@ claw_probe(struct ccwgroup_device *cgdev)
privptr->p_env->p_priv = privptr;
cgdev->cdev[0]->handler = claw_irq_handler;
cgdev->cdev[1]->handler = claw_irq_handler;
cgdev->dev.driver_data = privptr;
CLAW_DBF_TEXT(2, setup, "prbext 0");
return 0;
......@@ -1963,16 +1963,13 @@ probe_error( struct ccwgroup_device *cgdev)
struct claw_privbk *privptr;
CLAW_DBF_TEXT(4, trace, "proberr");
privptr=(struct claw_privbk *)cgdev->dev.driver_data;
if (privptr!=NULL) {
privptr = (struct claw_privbk *) cgdev->dev.driver_data;
if (privptr != NULL) {
cgdev->dev.driver_data = NULL;
kfree(privptr->p_env);
privptr->p_env=NULL;
kfree(privptr->p_mtc_envelope);
privptr->p_mtc_envelope=NULL;
kfree(privptr);
privptr=NULL;
}
return;
} /* probe_error */
/*-------------------------------------------------------------------*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment