[PATCH] bridge: Fix resource leak

Patrik Flykt patrik.flykt at linux.intel.com
Tue Nov 13 04:15:57 PST 2012


	Hi,

On Fri, 2012-11-09 at 14:48 +0900, Danny Jeongseok Seo wrote:
> diff --git a/src/bridge.c b/src/bridge.c
> index 2849ef7..47467e6 100644
> --- a/src/bridge.c
> +++ b/src/bridge.c
> @@ -76,7 +76,9 @@ int __connman_bridge_create(const char *name)
>  	if (ioctl(sk, SIOCBRADDBR, name) == -1) {
>  		err = -errno;
>  		if (err != -EEXIST)
> -			return -EOPNOTSUPP;
> +			err = -EOPNOTSUPP;
> +
> +		goto done;

If the error is EEXIST, the bridge exists already and everything is ok.
In this case we don't signal an error with the unconditional goto.

I made the following fix below.

Cheers,

	Patrik



diff --git a/src/bridge.c b/src/bridge.c
index 2849ef7..e46cdda 100644
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -75,8 +75,10 @@ int __connman_bridge_create(const char *name)
 
 	if (ioctl(sk, SIOCBRADDBR, name) == -1) {
 		err = -errno;
-		if (err != -EEXIST)
+		if (err != -EEXIST) {
+			close(sk);
 			return -EOPNOTSUPP;
+		}
 	}
 
 	err = set_forward_delay(name, 0);





More information about the connman mailing list