Skip to content

Commit

Permalink
ieee1394: eth1394: fix error path in module_init
Browse files Browse the repository at this point in the history
This patch fixes some error handlings in eth1394:

- check return value of kmem_cache_create()
- cleanup resources if hpsb_register_protocol() fails

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (whitespace)
  • Loading branch information
Akinobu Mita authored and Stefan Richter committed Apr 29, 2007
1 parent fdc0092 commit 809e905
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/ieee1394/eth1394.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,17 +1667,26 @@ static struct ethtool_ops ethtool_ops = {
.get_drvinfo = ether1394_get_drvinfo
};

static int __init ether1394_init_module (void)
static int __init ether1394_init_module(void)
{
int err;

packet_task_cache = kmem_cache_create("packet_task",
sizeof(struct packet_task),
0, 0, NULL, NULL);
if (!packet_task_cache)
return -ENOMEM;

hpsb_register_highlevel(&eth1394_highlevel);
return hpsb_register_protocol(&eth1394_proto_driver);
err = hpsb_register_protocol(&eth1394_proto_driver);
if (err) {
hpsb_unregister_highlevel(&eth1394_highlevel);
kmem_cache_destroy(packet_task_cache);
}
return err;
}

static void __exit ether1394_exit_module (void)
static void __exit ether1394_exit_module(void)
{
hpsb_unregister_protocol(&eth1394_proto_driver);
hpsb_unregister_highlevel(&eth1394_highlevel);
Expand Down

0 comments on commit 809e905

Please sign in to comment.