mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -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);
|
||||
if (dev_fd<=0) {
|
||||
perror("Could not open /dev/xen/gntdev! Have you loaded the xen_gntdev module?");
|
||||
close(alloc_fd);
|
||||
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_);
|
||||
if (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*/
|
||||
|
|
@ -610,7 +611,7 @@ static int alloc_gref(struct ioctl_gntalloc_alloc_gref *gref_, void **addr) {
|
|||
if (*addr == MAP_FAILED) {
|
||||
*addr = 0;
|
||||
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",
|
||||
|
|
@ -626,7 +627,7 @@ static int alloc_gref(struct ioctl_gntalloc_alloc_gref *gref_, void **addr) {
|
|||
if (rv)
|
||||
pa_log_debug("gntalloc unmap notify error: %s (rv=%d)\n", strerror(errno), rv);
|
||||
*/
|
||||
|
||||
finish:
|
||||
close(alloc_fd);
|
||||
close(dev_fd);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue