aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/jazzsonic.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-11-05 16:20:47 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-11-05 16:20:47 -0500
commit95cb5d954ee656a0b048ea2298188569e0759336 (patch)
tree3283cd23477bad8d3a418e6f501b39145bfd54b8 /drivers/net/jazzsonic.c
parent5d994b7f5d1c77acaa0b9b4c1b9f0f278605c309 (diff)
[DRIVER MODEL] Fix jazzsonic
Release code in driver modules is a potential cause of oopsen. The device may be in use by a userspace process, which will keep a reference to the device. If the module is unloaded, the module text will be freed. Subsequently, when the last reference is dropped, the release code will be called, which no longer exists. Use generic platform device allocation/release code in modules. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/net/jazzsonic.c')
-rw-r--r--drivers/net/jazzsonic.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index a74a5cfaf5bc..2fb3101cb33e 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -285,18 +285,8 @@ static struct device_driver jazz_sonic_driver = {
285 .remove = __devexit_p(jazz_sonic_device_remove), 285 .remove = __devexit_p(jazz_sonic_device_remove),
286}; 286};
287 287
288static void jazz_sonic_platform_release (struct device *device)
289{
290 struct platform_device *pldev;
291
292 /* free device */
293 pldev = to_platform_device (device);
294 kfree (pldev);
295}
296
297static int __init jazz_sonic_init_module(void) 288static int __init jazz_sonic_init_module(void)
298{ 289{
299 struct platform_device *pldev;
300 int err; 290 int err;
301 291
302 if ((err = driver_register(&jazz_sonic_driver))) { 292 if ((err = driver_register(&jazz_sonic_driver))) {
@@ -304,27 +294,19 @@ static int __init jazz_sonic_init_module(void)
304 return err; 294 return err;
305 } 295 }
306 296
307 jazz_sonic_device = NULL; 297 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0);
308 298 if (!jazz_sonnic_device)
309 if (!(pldev = kmalloc (sizeof (*pldev), GFP_KERNEL))) {
310 goto out_unregister; 299 goto out_unregister;
311 }
312 300
313 memset(pldev, 0, sizeof (*pldev)); 301 if (platform_device_add(jazz_sonic_device)) {
314 pldev->name = jazz_sonic_string; 302 platform_device_put(jazz_sonic_device);
315 pldev->id = 0;
316 pldev->dev.release = jazz_sonic_platform_release;
317 jazz_sonic_device = pldev;
318
319 if (platform_device_register (pldev)) {
320 kfree(pldev);
321 jazz_sonic_device = NULL; 303 jazz_sonic_device = NULL;
322 } 304 }
323 305
324 return 0; 306 return 0;
325 307
326out_unregister: 308out_unregister:
327 platform_device_unregister(pldev); 309 driver_unregister(&jazz_sonic_driver);
328 310
329 return -ENOMEM; 311 return -ENOMEM;
330} 312}