aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libdvbv5/dvb-dev-local.c
AgeCommit message (Collapse)AuthorFilesLines
2019-03-17libdvbv5: leaks and double free in dvb_fe_open_fname()HEADmasterSean Young1-1/+1
dvb_fe_open_fname() takes ownership of fname if the function succeeds, but also in two of the error paths (e.g. if the ioctl FE_GET_PROPERTY fails). Adjust dvb_fe_open_fname() so it copies fname rather than taking ownership (and passing that to params). This makes the code cleaner. Signed-off-by: Sean Young <sean@mess.org>
2018-07-30libdvbv5/v4l2-compliance: fix select() gcc-8.1 warningsHans Verkuil1-4/+8
The same fds argument is passed twice to the select() call. This leads (with gcc 8.1) to this warning (same warning for v4l2-compliance): dvb-dev-local.c:614:7: warning: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Wrestrict] &set, NULL, &set, NULL)); ^~~~ ~~~~ Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
2018-04-26libdvb5: Fix unused local variable warningsSakari Ailus1-2/+3
Some local variables are only needed conditionally depending on available system support for e.g. pthreads. Put these variables behind same #ifdefs so that no warnings are produced if these features aren't available. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Acked-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2018-03-06libdvbv5: fix musl compilePeter Seiderer1-0/+9
Add optional copy of TEMP_FAILURE_RETRY macro in order to fix musl compile. Fixes: ../../lib/libdvbv5/.libs/libdvbv5.so: undefined reference to `TEMP_FAILURE_RETRY' Signed-off-by: Peter Seiderer <ps.report@gmx.net>
2017-12-14libdvbv5: be sure that interruped reads will be handledMauro Carvalho Chehab1-3/+4
It is possible that the read() ioctl would return a temporary error, as documented at glibc texinfo pages: "A signal can arrive and be handled while an I/O primitive such as ‘open’ or ‘read’ is waiting for an I/O device. If the signal handler returns, the system faces the question: what should happen next? POSIX specifies one approach: make the primitive fail right away. The error code for this kind of failure is ‘EINTR’. This is flexible, but usually inconvenient. Typically, POSIX applications that use signal handlers must check for ‘EINTR’ after each library function that can return it, in order to try the call again. Often programmers forget to check, which is a common source of error. The GNU C Library provides a convenient way to retry a call after a temporary failure, with the macro ‘TEMP_FAILURE_RETRY’" So, improve the read logic in order to handle such cases. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-12-13dvb_local_read: ignore EAGAINRafaël Carré1-1/+1
If the device has been opened with O_NONBLOCK, EAGAIN is a legitimate error Signed-off-by: Rafaël Carré <funman@videolan.org>
2017-11-29libdvbv5: accept DVBv5 calls from dvbloopback againMauro Carvalho Chehab1-2/+1
Now that dvbloopback support for FE_GET_PROPERTY and FE_SET_PROPERTY got fixed: https://github.com/bas-t/dvbloopback/commit/f47e792df669b47c4574e213dfee16b38f382e73 Change the logic to also accept DVBv5 API calls. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-11-27dvb: better cope with dvbloopbackMauro Carvalho Chehab1-1/+36
The dvbloopback OOT Kernel module is a dirty hack. It requires a Kernel patch that breaks the DVB core, removing mutex_lock(&dvbdev_mutex) during DVB open. Also, support for FE_GET_PROPERTY/FE_SET_PROPERTY is broken: it causes the Kernel to crash with: dvblb_poll 0frontend1: fd:0 BUG: unable to handle kernel paging request at 00007ffff41561c0 IP: dvblb_ioctl+0x428/0x6e0 [dvbloopback] Yet, it seems that users are trying to use it on some enviroments, as I got some reports that libdvbv5 doesn't handle it well. So, let's add some workarounds on libdvbv5, in order to make it work. There is a catch, though: without libdvbv5, it won't support second generation TV standards, like DVB-S2 and DVB-T2. This changeset works around 3 issues with dvbloopback: 1) only frontend0/dvr0/demux0/.. is used as a normal dvb adapter. The second ones are used by an special userspace interface, with shouldn't be vibible by libdvbv5 applications; 2) it expects that the device is opened with O_NONBLOCK; 3) the DVBv5 API support is broken. So, fallback to DVBv3. Tested using https://github.com/bas-t/dvbloopback, with is the first occurrence on Google for dvbloopback here. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-11-16dvb_dev_get_fd(): return fd of local devicesRafaël Carré1-0/+6
This makes it possible to poll a local device. Getting the fd is preferrable to adding a dvb_dev_poll() function, because we can poll several fds together in an event-based program. This is not implemented for remote devices, as polling a remote fd does not make sense. We could instead return the socket to know when to expect messages from the remote device, but the current implementation in dvb-dev-remote.c already runs a thread to receive remote messages as soon as possible. Signed-off-by: Rafaël Carré <funman@videolan.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-11-16dvb_local_open(): strdup fname before calling dvb_fe_open_fname()Rafaël Carré1-1/+1
Issue spotted by valgrind: ==5290== Invalid free() / delete / delete[] / realloc() ==5290== at 0x4C30D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5290== by 0x4E54401: free_dvb_dev (dvb-dev.c:49) ==5290== by 0x4E5449A: dvb_dev_free_devices (dvb-dev.c:94) ==5290== by 0x4E547BA: dvb_dev_free (dvb-dev.c:121) ==5290== by 0x10881A: main (leak.c:26) ==5290== Address 0x5e55910 is 0 bytes inside a block of size 28 free'd ==5290== at 0x4C30D3B: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5290== by 0x4E56504: dvb_v5_free (dvb-fe.c:85) ==5290== by 0x4E547B2: dvb_dev_free (dvb-dev.c:119) ==5290== by 0x10881A: main (leak.c:26) ==5290== Block was alloc'd at ==5290== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==5290== by 0x5119C39: strdup (strdup.c:42) ==5290== by 0x4E55B42: handle_device_change (dvb-dev-local.c:137) ==5290== by 0x4E561DA: dvb_local_find (dvb-dev-local.c:323) ==5290== by 0x10880E: main (leak.c:10) Signed-off-by: Rafaël Carré <funman@videolan.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-09-12dvb-dev-local: fix pthread checksMauro Carvalho Chehab1-2/+8
If there's no pthread at all, it doesn't make sense to include pthread.h, nor to use pthread_t typedef. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-16dvb-dev: add a method to get device info from sysnameMauro Carvalho Chehab1-18/+26
Sometimes, it is needed to be able to retrieve data from sysname. Add a method to retrieve that. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-16dvb-dev: rename the function that gets the sysname of a deviceMauro Carvalho Chehab1-2/+2
Despite its name, what this function really does is to seek a device, based on its adapter. So, name it accordingly. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2017-03-06dvb-dev: allow passing an optional void pointer parameter to dvb_dev_find()Mauro Carvalho Chehab1-3/+7
The notify callback may need to use some context data on notifications. Add support for it. As the dvb-dev.h API was broken on the past versions, because it was including ./config.h header file on it, there's no actual API breakage on this patch. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-09-13dvbv5: use asynchronous read for dvbv5-daemonMauro Carvalho Chehab1-1/+3
When using dvbv5-zap on monitor mode, it loses packets over the network connection, even with two local machines. Change the logic to let the DVB reads be asynchronous: the dvbv5-daemon will now poll all open demux and dvr device nodes. When some data arrives there, it sends through the network. We're using a sufficiently large buffer there to avoid loses. This increases the delay, but, as we're already using the network, delays are unavoidable. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-29libdvbv5: better handle overflow errorsMauro Carvalho Chehab1-1/+2
There are some issues with handling overflow errors after the addition of remote access. Address them. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-08libdvbv5: fix device changes notificationMauro Carvalho Chehab1-11/+16
Added an option at dvb-fe-tool to monitor device insert/removal, and fixed some bugs at its logic. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-08libdvbv5: add local logic for device detection notifierMauro Carvalho Chehab1-35/+107
Implement a notification thread to report device detect. Please notice that this code was compile-tested only, as we need to add support on some userspace app to be able to test it. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-07libdvbv5: while not too late, change dvb_dev_find() apiMauro Carvalho Chehab1-2/+3
While we're still experimental, change the monitor API to pass a pointer to a notify callback. The code to handle it should be made on a separate path. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-07libdvbv5: better handle local errorsMauro Carvalho Chehab1-18/+22
There are some mess at error handling logic: sometimes, it returns errors as positive values, sometimes as negative. Also, on several places, it just return a random negative number. Always use negative numbers for errors, and use the Kernel error codes, to make it more portable. Also, as errors can now be reported to the remote end, if the error is filled at errno, return it via the return function parameter where possible. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-07libdvbv5: Fix some allocation issuesMauro Carvalho Chehab1-5/+5
Valgrind reports about some allocation issues at dvb-dev. Address them. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-06libdvbv5: Fix remote read()Mauro Carvalho Chehab1-0/+4
There were several small bugs making read() unreliable when used over a remote connection. Address them. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-06libdvbv5: allow overriding the main FE functionsMauro Carvalho Chehab1-0/+29
As we want to use remote DVB devices, those functions are needed. Please notice that we still lack Satellite support, as we're not overriding SEC-related functions yet. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-08-06libdvbv5: prepare to add remote support for dvb_dev* functionsMauro Carvalho Chehab1-8/+48
With a remote end, all functions may return errors. So, change all routines to return an error. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-28libdvbv5: abstract the dvb_dev functionsMauro Carvalho Chehab1-188/+36
Abstract the dvb_dev functions. This way, we can override its implementation by one that would allow accessing remote devices too. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
2016-07-28libdvbv5: rename dvb-dev.c to dvb-dev-local.cMauro Carvalho Chehab1-0/+783
As we'll be implementing support for remote devices, let's first rename the implementation of the local DVB access routines to dvb-dev-local.c. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

Privacy Policy