s390: correct misuses of module_put in appldata_generic_handler.
PATCH 1/1 s390: correct misuses of module_put in appldata_generic_handler.
correct misuses of module_put in appldata_generic_handler
--- arch/s390/appldata/appldata_base.c | 3 --- 1 file changed, 3 deletions(-)
arch/s390/appldata/appldata_base.c +0 -3
@@ -343,7 +343,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,// protect work queue callback if (!try_module_get (ops->owner)) {mutex_unlock (&appldata_ops_mutex); -module_put (ops->owner);return -ENODEV ; } ops->callback (ops->data);// init record
@@ -354,7 +353,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 ) {pr_err ("Starting the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }else ops->active =1 ; }else if ((buf[0 ] =='0' ) && (ops->active ==1 )) {
@@ -365,7 +363,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 )pr_err ("Stopping the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }mutex_unlock (&appldata_ops_mutex); out:
Signature · 1 line
1.8.1.2
Quoted 1 line · On Sat, 15 Mar 2014 21:35:40 +0800 Zhouyi Zhou <[email protected]> wrote:
correct misuses of
module_putinappldata_generic_handler
Sorry, I don't see any misuse, could you elaborate?
Quoted 34 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- arch/s390/appldata/appldata_base.c | 3 --- 1 file changed, 3 deletions(-)arch/s390/appldata/appldata_base.c +0
-3@@ -343,7 +343,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,// protect work queue callback if (!try_module_get (ops->owner)) {mutex_unlock (&appldata_ops_mutex); -module_put (ops->owner);return -ENODEV ; } ops->callback (ops->data);// init record @@ -354,7 +353,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 ) {pr_err ("Starting the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }else ops->active =1 ; }else if ((buf[0 ] =='0' ) && (ops->active ==1 )) {@@ -365,7 +363,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 )pr_err ("Stopping the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }mutex_unlock (&appldata_ops_mutex); out:
Thanks Gerald for reviewing and sorry for not elaborated it in the e-mail.
Firstly, I think you can't call module_put after fail try_module_get
Secondly, there exists duplicate module_put on the program path (the last one is before return 0)
Quoted 42 lines · Gerald Schaefer
Quoted 1 line · On Sat, 15 Mar 2014 21:35:40 +0800 Zhouyi Zhou <[email protected]> wrote:
correct misuses of
module_putinappldata_generic_handlerSorry, I don't see any misuse, could you elaborate?
Quoted 34 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- arch/s390/appldata/appldata_base.c | 3 --- 1 file changed, 3 deletions(-)arch/s390/appldata/appldata_base.c +0
-3@@ -343,7 +343,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,// protect work queue callback if (!try_module_get (ops->owner)) {mutex_unlock (&appldata_ops_mutex); -module_put (ops->owner);return -ENODEV ; } ops->callback (ops->data);// init record @@ -354,7 +353,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 ) {pr_err ("Starting the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }else ops->active =1 ; }else if ((buf[0 ] =='0' ) && (ops->active ==1 )) {@@ -365,7 +363,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 )pr_err ("Stopping the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }mutex_unlock (&appldata_ops_mutex); out:
Quoted 3 lines · On Tue, 18 Mar 2014 09:24:55 +0800 Zhouyi Zhou <[email protected]> wrote:
Thanks Gerald for reviewing and sorry for not elaborated it in the e-mail.
Firstly, I think you can't call
module_putafter failtry_module_get
There is another try_module_get() in this function before that, so I need to call module_put() once if the second try_module_get() fails.
The first try_module_get() is only needed within the function, while the second one is needed to prevent a module from being unloaded while its callback is registered, so that reference is kept as long as the module is active.
Quoted 3 lines
Secondly, there exists duplicate
module_puton the program path (the last one is before return 0)
There is one module_put() for every try_module_get(). If "1" is written to the sysctl, the function exits with one "missing" module_put(), which is held to protect the callback. When "0" is written, this reference is returned again with an "extra" module_put().
Quoted 50 lines
Quoted 33 lines · Gerald Schaefer
Quoted 1 line · On Sat, 15 Mar 2014 21:35:40 +0800 Zhouyi Zhou <[email protected]> wrote:
correct misuses of
module_putinappldata_generic_handlerSorry, I don't see any misuse, could you elaborate?
Quoted 26 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- arch/s390/appldata/appldata_base.c | 3 --- 1 file changed, 3 deletions(-)arch/s390/appldata/appldata_base.c +0
-2@@ -343,7 +343,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,// protect work queue callback if (!try_module_get (ops->owner)) {mutex_unlock (&appldata_ops_mutex); -module_put (ops->owner);return -ENODEV ; } ops->callback (ops->data);// init record @@ -354,7 +353,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 ) {pr_err ("Starting the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }else ops->active =1 ; }else if ((buf[0 ] =='0' ) && (ops->active ==1 )) {Quoted 9 lines
arch/s390/appldata/appldata_base.c appldata_generic_handler(struct ctl_table *ctl, int write, · line 368
Quoted 8 lines
arch/s390/appldata/appldata_base.c +0
-1@@ -365,7 +363,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 )pr_err ("Stopping the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }mutex_unlock (&appldata_ops_mutex); out:--
To unsubscribe from this list: send the line "unsubscribe linux-s390" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Delicate design! thanks for replying, sorry for the trouble
Quoted 75 lines · Gerald Schaefer
Quoted 3 lines · On Tue, 18 Mar 2014 09:24:55 +0800 Zhouyi Zhou <[email protected]> wrote:
Thanks Gerald for reviewing and sorry for not elaborated it in the e-mail.
Firstly, I think you can't call
module_putafter failtry_module_getThere is another
try_module_get()in this function before that, so I need to callmodule_put()once if the secondtry_module_get()fails.The first
try_module_get()is only needed within the function, while the second one is needed to prevent a module from being unloaded while its callback is registered, so that reference is kept as long as the module is active.Quoted 3 lines
Secondly, there exists duplicate
module_puton the program path (the last one is before return 0)There is one
module_put()for everytry_module_get(). If "1" is written to the sysctl, the function exits with one "missing"module_put(), which is held to protect the callback. When "0" is written, this reference is returned again with an "extra"module_put().Quoted 50 lines
Quoted 33 lines · Gerald Schaefer
Quoted 1 line · On Sat, 15 Mar 2014 21:35:40 +0800 Zhouyi Zhou <[email protected]> wrote:
correct misuses of
module_putinappldata_generic_handlerSorry, I don't see any misuse, could you elaborate?
Quoted 26 lines
Signed-off-by Zhouyi Zhou <[email protected]>--- arch/s390/appldata/appldata_base.c | 3 --- 1 file changed, 3 deletions(-)arch/s390/appldata/appldata_base.c +0
-2@@ -343,7 +343,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,// protect work queue callback if (!try_module_get (ops->owner)) {mutex_unlock (&appldata_ops_mutex); -module_put (ops->owner);return -ENODEV ; } ops->callback (ops->data);// init record @@ -354,7 +353,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 ) {pr_err ("Starting the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }else ops->active =1 ; }else if ((buf[0 ] =='0' ) && (ops->active ==1 )) {Quoted 9 lines
arch/s390/appldata/appldata_base.c appldata_generic_handler(struct ctl_table *ctl, int write, · line 368
Quoted 8 lines
arch/s390/appldata/appldata_base.c +0
-1@@ -365,7 +363,6 @@ appldata_generic_handler(struct ctl_table *ctl, int write,if (rc !=0 )pr_err ("Stopping the data collection for %s " "failed with rc=%d\n" , ops->name, rc); -module_put (ops->owner); }mutex_unlock (&appldata_ops_mutex); out:--
To unsubscribe from this list: send the line "unsubscribe linux-s390" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html