diff mbox

media: dvb_usb_pctv452e: module refcount changes were unbalanced

Message ID 20171128113352.5jm3ur3bszey3y4l@rohdewald.de (mailing list archive)
State New, archived
Headers show

Commit Message

Wolfgang Rohdewald Nov. 28, 2017, 11:33 a.m. UTC
dvb_frontend will call dvb_detach for:
- stb0899_detach in dvb_frontend_release and
- stb0899_release in __dvb_frontend_free

But we only do dvb_attach(stb0899_attach).
Increment the module refcount instead.

Signed-off-by: Wolfgang Rohdewald <wolfgang@rohdewald.de>
---
 drivers/media/usb/dvb-usb/pctv452e.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Arnd Bergmann Dec. 18, 2017, 7:55 p.m. UTC | #1
On Tue, Nov 28, 2017 at 12:33 PM, Wolfgang Rohdewald
<wolfgang@rohdewald.de> wrote:

> @@ -913,6 +913,14 @@ static int pctv452e_frontend_attach(struct dvb_usb_adapter *a)
>                                                 &a->dev->i2c_adap);
>         if (!a->fe_adap[0].fe)
>                 return -ENODEV;
> +
> +       /*
> +        * dvb_frontend will call dvb_detach for both stb0899_detach
> +        * and stb0899_release but we only do dvb_attach(stb0899_attach).
> +        * Increment the module refcount instead.
> +        */
> +       symbol_get(stb0899_attach);
> +
>         if ((dvb_attach(lnbp22_attach, a->fe_adap[0].fe,
>                                         &a->dev->i2c_adap)) == NULL)
>                 err("Cannot attach lnbp22\n");

This caused a build error in today's linux-next:

In file included from drivers/media/usb/dvb-usb/pctv452e.c:20:0:
drivers/media/usb/dvb-usb/pctv452e.c: In function 'pctv452e_frontend_attach':
drivers/media/dvb-frontends/stb0899_drv.h:151:36: error: weak
declaration of 'stb0899_attach' being applied to a already existing,
static definition
 static inline struct dvb_frontend *stb0899_attach(struct
stb0899_config *config,

I don't really understand where the 'weak' declaration came from, but this seems
to be related to resolving a symbol for a function that was declared
'static inline'.

The random configuration that caused this included:

CONFIG_DVB_USB_PCTV452E=y
# CONFIG_DVB_STB0899 is not set
# CONFIG_MODULES is not set

       Arnd
diff mbox

Patch

diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c
index 601ade7ca48d..3b7f8298b24d 100644
--- a/drivers/media/usb/dvb-usb/pctv452e.c
+++ b/drivers/media/usb/dvb-usb/pctv452e.c
@@ -913,6 +913,14 @@  static int pctv452e_frontend_attach(struct dvb_usb_adapter *a)
 						&a->dev->i2c_adap);
 	if (!a->fe_adap[0].fe)
 		return -ENODEV;
+
+	/*
+	 * dvb_frontend will call dvb_detach for both stb0899_detach
+	 * and stb0899_release but we only do dvb_attach(stb0899_attach).
+	 * Increment the module refcount instead.
+	 */
+	symbol_get(stb0899_attach);
+
 	if ((dvb_attach(lnbp22_attach, a->fe_adap[0].fe,
 					&a->dev->i2c_adap)) == NULL)
 		err("Cannot attach lnbp22\n");