[snip]
} @@ -177,8 +180,17 @@
}
} /* Create the PC card device object. */
} link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
} - memset(link, 0, sizeof(struct dev_link_t));
} + if (!link)
} + return NULL;
} +
} link->dev = kmalloc(sizeof(struct dev_node_t), GFP_KERNEL);
} +
} + if (!link->dev) {
} + kfree(link);
} + return NULL;
} + }
} +
} + memset(link, 0, sizeof(struct dev_link_t));
} memset(link->dev, 0, sizeof(struct dev_node_t));
}
Are you sure this is correct? You are zeroing out the link structure
(which includes the kmalloc'ed link->dev pointer) and then trying to zero
out the link->dev pointer. It's a memory leak and NULL pointer reference.
How about this instead:
link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
if (!link)
return NULL;
memset(link, 0, sizeof(struct dev_link_t));
link->dev = kmalloc(sizeof(struct dev_node_t), GFP_KERNEL);
if (!link->dev) {
kfree(link);
return NULL;
}
memset(link->dev, 0, sizeof(struct dev_node_t));
} // dev = init_etherdev(0, sizeof(struct awc_private) );
^^ C++ style comments...blech! :)
-- || Bill Wendling wendling@ganymede.isdn.uiuc.edu- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/