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