mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
xen: Resource leak in local function alloc_gref() - alloc_fd and dev_fd
The file descriptors need to be closed in failure cases otherwise resource leak is there. Buglink: https://bugs.freedesktop.org/show_bug.cgi?id=91174#c0 Signed-off-by: Manish Sogi <manish.sogi@samsung.com>
This commit is contained in:
parent
8f12ef901c
commit
dd084acb28
1 changed files with 4 additions and 3 deletions
|
|
@ -591,6 +591,7 @@ static int alloc_gref(struct ioctl_gntalloc_alloc_gref *gref_, void **addr) {
|
||||||
dev_fd = open("/dev/xen/gntdev", O_RDWR);
|
dev_fd = open("/dev/xen/gntdev", O_RDWR);
|
||||||
if (dev_fd<=0) {
|
if (dev_fd<=0) {
|
||||||
perror("Could not open /dev/xen/gntdev! Have you loaded the xen_gntdev module?");
|
perror("Could not open /dev/xen/gntdev! Have you loaded the xen_gntdev module?");
|
||||||
|
close(alloc_fd);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -602,7 +603,7 @@ static int alloc_gref(struct ioctl_gntalloc_alloc_gref *gref_, void **addr) {
|
||||||
rv = ioctl(alloc_fd, IOCTL_GNTALLOC_ALLOC_GREF, gref_);
|
rv = ioctl(alloc_fd, IOCTL_GNTALLOC_ALLOC_GREF, gref_);
|
||||||
if (rv) {
|
if (rv) {
|
||||||
pa_log_debug("Xen audio sink: src-add error: %s (rv=%d)\n", strerror(errno), rv);
|
pa_log_debug("Xen audio sink: src-add error: %s (rv=%d)\n", strerror(errno), rv);
|
||||||
return rv;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*addr=NULL(default),length, prot, flags, fd, offset*/
|
/*addr=NULL(default),length, prot, flags, fd, offset*/
|
||||||
|
|
@ -610,7 +611,7 @@ static int alloc_gref(struct ioctl_gntalloc_alloc_gref *gref_, void **addr) {
|
||||||
if (*addr == MAP_FAILED) {
|
if (*addr == MAP_FAILED) {
|
||||||
*addr = 0;
|
*addr = 0;
|
||||||
pa_log_debug("Xen audio sink: mmap'ing shared page failed\n");
|
pa_log_debug("Xen audio sink: mmap'ing shared page failed\n");
|
||||||
return rv;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_log_debug("Xen audio sink: Got grant #%d. Mapped locally at %Ld=%p\n",
|
pa_log_debug("Xen audio sink: Got grant #%d. Mapped locally at %Ld=%p\n",
|
||||||
|
|
@ -626,7 +627,7 @@ static int alloc_gref(struct ioctl_gntalloc_alloc_gref *gref_, void **addr) {
|
||||||
if (rv)
|
if (rv)
|
||||||
pa_log_debug("gntalloc unmap notify error: %s (rv=%d)\n", strerror(errno), rv);
|
pa_log_debug("gntalloc unmap notify error: %s (rv=%d)\n", strerror(errno), rv);
|
||||||
*/
|
*/
|
||||||
|
finish:
|
||||||
close(alloc_fd);
|
close(alloc_fd);
|
||||||
close(dev_fd);
|
close(dev_fd);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue