MT#61856 media_socket: init fd to -1 when binding socket

When binding the port to a socket, init fd to -1
because 0 is actually a valid id for fd in the system,
this `struct socket_port_link spl = {0};` puts `.fd = 0`
and if socket binding fails, then `.fd == 0` which is
a totally valid fd.

Instead init it to -1 and then let `add_socket()` to
actually fill the structure's data properly,
if however that one fails to bind, then again return
`.fd = -1`.

Change-Id: Iaeeee534a66b43441253ddfe710c8163084ad444
master
Donat Zenichev 15 hours ago
parent 294b8140f1
commit 2bd4f4d311

@ -1225,9 +1225,12 @@ struct socket_port_link get_specific_port(unsigned int port,
{
if (!port_is_in_range(&spec->port_pool, port)) {
ilog(LOG_DEBUG, "A specific out-of-pool port is requested: '%d'", port);
struct socket_port_link spl = {0};
add_socket(&spl.socket, port, spec, label);
return spl;
struct socket_port_link spl = { .socket = { .fd = -1 } };
if (add_socket(&spl.socket, port, spec, label))
return spl;
return (struct socket_port_link) { .socket = { .fd = -1 } };
}
ilog(LOG_DEBUG, "A specific in-pool port is requested: '%d'", port);

Loading…
Cancel
Save