aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@linaro.org>2021-06-04 10:16:24 +0200
committerLoic Poulain <loic.poulain@linaro.org>2021-06-04 12:05:30 +0200
commit6fb7cbd0c0bde0de872744e89ee87e36ed8ec6a7 (patch)
tree9e91f578138dc38eacc3fb0ed7a3cb60c0c36240
parentfd7e6d78ebad9930d22e5b5f430cae9ad5fc89fe (diff)
[FIXUP] net: wwan: core: get module reference on ops registration
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
-rw-r--r--drivers/net/wwan/wwan_core.c7
-rw-r--r--include/linux/wwan.h2
2 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index 5829c00a7586d..bfe5e282dea8d 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -570,6 +570,11 @@ int wwan_register_ops(struct device *parent, const struct wwan_ops *ops,
return -EBUSY;
}
+ if (!try_module_get(ops->owner)) {
+ wwan_remove_dev(wwandev);
+ return -ENODEV;
+ }
+
wwandev->ops = ops;
wwandev->ops_ctxt = ctxt;
@@ -597,6 +602,8 @@ void wwan_unregister_ops(struct device *parent)
if (WARN_ON(!has_ops))
return;
+ module_put(wwandev->ops->owner);
+
wwandev->ops = NULL;
wwandev->ops_ctxt = NULL;
wwan_remove_dev(wwandev);
diff --git a/include/linux/wwan.h b/include/linux/wwan.h
index d07301962ff7e..1116b5227df5c 100644
--- a/include/linux/wwan.h
+++ b/include/linux/wwan.h
@@ -111,12 +111,14 @@ void *wwan_port_get_drvdata(struct wwan_port *port);
/**
* struct wwan_ops - WWAN device ops
+ * @owner: module owner of the WWAN ops
* @priv_size: size of private netdev data area
* @setup: set up a new netdev
* @newlink: register the new netdev
* @dellink: remove the given netdev
*/
struct wwan_ops {
+ struct module *owner;
unsigned int priv_size;
void (*setup)(struct net_device *dev);
int (*newlink)(void *ctxt, struct net_device *dev,