diff mbox series

[v2,3/8] usb: gadget: uvc: configfs: Drop leaked references to config items

Message ID 20180801215505.7658-4-laurent.pinchart@ideasonboard.com (mailing list archive)
State New, archived
Headers show
Series usb: gadget: uvc: Improve configfs support | expand

Commit Message

Laurent Pinchart Aug. 1, 2018, 9:55 p.m. UTC
Some of the .allow_link() and .drop_link() operations implementations
call config_group_find_item() and then leak the reference to the
returned item. Fix this by dropping those references where needed.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/usb/gadget/function/uvc_configfs.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kieran Bingham Sept. 24, 2018, 11:44 a.m. UTC | #1
Hi Laurent,

On 01/08/18 22:55, Laurent Pinchart wrote:
> Some of the .allow_link() and .drop_link() operations implementations
> call config_group_find_item() and then leak the reference to the
> returned item. Fix this by dropping those references where needed.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  drivers/usb/gadget/function/uvc_configfs.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
> index dbc95c9558de..8d513cc6fb8c 100644
> --- a/drivers/usb/gadget/function/uvc_configfs.c
> +++ b/drivers/usb/gadget/function/uvc_configfs.c
> @@ -529,6 +529,7 @@ static int uvcg_control_class_allow_link(struct config_item *src,
>  unlock:
>  	mutex_unlock(&opts->lock);
>  out:
> +	config_item_put(header);
>  	mutex_unlock(su_mutex);
>  	return ret;
>  }
> @@ -564,6 +565,7 @@ static void uvcg_control_class_drop_link(struct config_item *src,
>  unlock:
>  	mutex_unlock(&opts->lock);
>  out:
> +	config_item_put(header);
>  	mutex_unlock(su_mutex);
>  }
>  
> @@ -2026,6 +2028,7 @@ static int uvcg_streaming_class_allow_link(struct config_item *src,
>  unlock:
>  	mutex_unlock(&opts->lock);
>  out:
> +	config_item_put(header);
>  	mutex_unlock(su_mutex);
>  	return ret;
>  }
> @@ -2066,6 +2069,7 @@ static void uvcg_streaming_class_drop_link(struct config_item *src,
>  unlock:
>  	mutex_unlock(&opts->lock);
>  out:
> +	config_item_put(header);
>  	mutex_unlock(su_mutex);
>  }
>  
>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c
index dbc95c9558de..8d513cc6fb8c 100644
--- a/drivers/usb/gadget/function/uvc_configfs.c
+++ b/drivers/usb/gadget/function/uvc_configfs.c
@@ -529,6 +529,7 @@  static int uvcg_control_class_allow_link(struct config_item *src,
 unlock:
 	mutex_unlock(&opts->lock);
 out:
+	config_item_put(header);
 	mutex_unlock(su_mutex);
 	return ret;
 }
@@ -564,6 +565,7 @@  static void uvcg_control_class_drop_link(struct config_item *src,
 unlock:
 	mutex_unlock(&opts->lock);
 out:
+	config_item_put(header);
 	mutex_unlock(su_mutex);
 }
 
@@ -2026,6 +2028,7 @@  static int uvcg_streaming_class_allow_link(struct config_item *src,
 unlock:
 	mutex_unlock(&opts->lock);
 out:
+	config_item_put(header);
 	mutex_unlock(su_mutex);
 	return ret;
 }
@@ -2066,6 +2069,7 @@  static void uvcg_streaming_class_drop_link(struct config_item *src,
 unlock:
 	mutex_unlock(&opts->lock);
 out:
+	config_item_put(header);
 	mutex_unlock(su_mutex);
 }