Commit f55c3d5c authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Make PPP compressors unload-safe.

Remove MOD_{INC,DEC}_USE_COUNT and introduce .owner instead.
parent 0f36c6e3
......@@ -300,7 +300,6 @@ static void bsd_free (void *state)
* Finally release the structure itself.
*/
kfree (db);
MOD_DEC_USE_COUNT;
}
}
......@@ -355,8 +354,6 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
return NULL;
}
MOD_INC_USE_COUNT;
/*
* If this is the compression buffer then there is no length data.
* For decompression, the length information is needed as well.
......@@ -907,6 +904,7 @@ static int bsd_decompress (void *state, struct sk_buff *skb_in, struct sk_buff *
*************************************************************/
static struct isdn_ppp_compressor ippp_bsd_compress = {
.owner = THIS_MODULE,
.num = CI_BSD_COMPRESS,
.alloc = bsd_alloc,
.free = bsd_free,
......
......@@ -259,11 +259,14 @@ ippp_ccp_free(struct ippp_ccp *ccp)
{
int id;
if (ccp->comp_stat)
if (ccp->comp_stat) {
ccp->compressor->free(ccp->comp_stat);
if (ccp->decomp_stat)
module_put(ccp->compressor->owner);
}
if (ccp->decomp_stat) {
ccp->decompressor->free(ccp->decomp_stat);
module_put(ccp->decompressor->owner);
}
for (id = 0; id < 256; id++) {
if (ccp->reset->rs[id])
ippp_ccp_reset_free_state(ccp, id);
......@@ -572,25 +575,34 @@ ippp_ccp_set_compressor(struct ippp_ccp *ccp, int unit,
if (ipc->num != num)
continue;
if (!try_module_get(ipc->owner))
continue;
stat = ipc->alloc(data);
if (!stat) {
printk(KERN_ERR "Can't alloc (de)compression!\n");
module_put(ipc->owner);
break;
}
ret = ipc->init(stat, data, unit, 0);
if(!ret) {
printk(KERN_ERR "Can't init (de)compression!\n");
ipc->free(stat);
module_put(ipc->owner);
break;
}
if (data->flags & IPPP_COMP_FLAG_XMIT) {
if (ccp->comp_stat)
if (ccp->comp_stat) {
ccp->compressor->free(ccp->comp_stat);
module_put(ccp->compressor->owner);
}
ccp->comp_stat = stat;
ccp->compressor = ipc;
} else {
if (ccp->decomp_stat)
if (ccp->decomp_stat) {
ccp->decompressor->free(ccp->decomp_stat);
module_put(ccp->decompressor->owner);
}
ccp->decomp_stat = stat;
ccp->decompressor = ipc;
}
......
......@@ -95,6 +95,7 @@ struct isdn_ppp_resetparams {
* check the original include for more information
*/
struct isdn_ppp_compressor {
struct module *owner;
struct isdn_ppp_compressor *next, *prev;
int num; /* CCP compression protocol number */
......
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