alistair23-linux/drivers/media/dvb-core
Mauro Carvalho Chehab ead666000a media: dvb_frontend: only use kref after initialized
As reported by Laurent, when a DVB frontend need to register
two drivers (e. g. a tuner and a demod), if the second driver
fails to register (for example because it was not compiled),
the error handling logic frees the frontend by calling
dvb_frontend_detach(). That used to work fine, but changeset
1f862a68df ("[media] dvb_frontend: move kref to struct dvb_frontend")
added a kref at struct dvb_frontend. So, now, instead of just
freeing the data, the error handling do a kref_put().

That works fine only after dvb_register_frontend() succeeds.

While it would be possible to add a helper function that
would be initializing earlier the kref, that would require
changing every single DVB frontend on non-trivial ways, and
would make frontends different than other drivers.

So, instead of doing that, let's focus on the real issue:
only call kref_put() after kref_init(). That's easy to
check, as, when the dvb frontend is successfuly registered,
it will allocate its own private struct. So, if such
struct is allocated, it means that it is safe to use
kref_put(). If not, then nobody is using yet the frontend,
and it is safe to just deallocate it.

Fixes: 1f862a68df ("[media] dvb_frontend: move kref to struct dvb_frontend")

Reported-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-10-11 12:47:36 -04:00
..
demux.h media: dvb-core/demux.h: fix kernel-doc warning 2017-07-21 08:01:08 -04:00
dmxdev.c media: get rid of removed DMX_GET_CAPS and DMX_SET_SOURCE leftovers 2017-09-05 08:25:07 -04:00
dmxdev.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb-usb-ids.h media: Added support for the TerraTec T1 DVB-T USB tuner [IT9135 chipset] 2017-07-20 16:46:49 -04:00
dvb_ca_en50221.c media: dvb_ca_en50221: Fixed multiple blank lines 2017-07-20 15:40:50 -04:00
dvb_ca_en50221.h media: dvb_ca_en50221.h: fix checkpatch strict warnings 2017-07-20 15:47:07 -04:00
dvb_demux.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
dvb_demux.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_frontend.c media: dvb_frontend: only use kref after initialized 2017-10-11 12:47:36 -04:00
dvb_frontend.h [media] docs-rst: media: better document refcount in struct dvb_frontend 2017-04-17 16:55:38 -03:00
dvb_math.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_math.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_net.c networking: make skb_put & friends return void pointers 2017-06-16 11:48:39 -04:00
dvb_net.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_ringbuffer.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvb_ringbuffer.h scripts/spelling.txt: add "an user" pattern and fix typo instances 2017-02-27 18:43:46 -08:00
dvbdev.c [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
dvbdev.h [media] media: Drop FSF's postal address from the source code files 2017-01-27 11:38:09 -02:00
Kconfig [media] Raise adapter number limit 2016-11-23 13:28:43 -02:00
Makefile [media] dvb-core: move dvb_filter out of the DVB core 2016-10-21 08:44:08 -02:00