Skip to contentSkip to conversation

usb: gadget: uvc: fix some error codes

PATCH In review Dan Carpenter 3 participants 3 messages Jan 14, 2015 – Jan 18, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 usb: gadget: uvc: fix some error codes

We're basically saying ERR_CAST(NULL) and PTR_ERR(NULL) here, which is nonsensical.

drivers/usb/gadget/function/uvc_configfs.c +7 -7
index 33d92ab..d112c99 100644
@@ -148,7 +148,7 @@ static struct config_item *uvcg_control_header_make(struct config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->desc.bLength			= UVC_DT_HEADER_SIZE(1);
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -840,7 +840,7 @@ static int uvcg_streaming_header_allow_link(struct config_item *src,
 
 	format_ptr = kzalloc(sizeof(*format_ptr), GFP_KERNEL);
 	if (!format_ptr) {
-		ret = PTR_ERR(format_ptr);
+		ret = -ENOMEM;
 		goto out;
 	}
 	ret = 0;
@@ -960,7 +960,7 @@ static struct config_item
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	INIT_LIST_HEAD(&h->formats);
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -1278,7 +1278,7 @@ static struct config_item *uvcg_frame_make(struct config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->frame.b_descriptor_type		= USB_DT_CS_INTERFACE;
 	h->frame.b_frame_index			= 1;
@@ -1563,7 +1563,7 @@ static struct config_group *uvcg_uncompressed_make(struct config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->desc.bLength			= UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -1772,7 +1772,7 @@ static struct config_group *uvcg_mjpeg_make(struct config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->desc.bLength			= UVC_DT_FORMAT_MJPEG_SIZE;
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -2124,7 +2124,7 @@ static int uvcg_streaming_class_allow_link(struct config_item *src,
 	count += 2; /* color_matching, NULL */
 	*class_array = kcalloc(count, sizeof(void *), GFP_KERNEL);
 	if (!*class_array) {
-		ret = PTR_ERR(*class_array);
+		ret = -ENOMEM;
 		goto unlock;
 	}
 
Acked-by on v1 1/6
#1 lore raw

W dniu 14.01.2015 o 21:59, Dan Carpenter pisze:

Quoted 4 lines

We're basically saying ERR_CAST(NULL) and PTR_ERR(NULL) here, which is nonsensical.

Quoted 73 lines
drivers/usb/gadget/function/uvc_configfs.c +7 -8
index 33d92ab..d112c99 100644
@@ -148,7 +148,7 @@ static struct config_item *uvcg_control_header_make(struct config_group *group,
 
  	h = kzalloc(sizeof(*h), GFP_KERNEL);
  	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
  	h->desc.bLength			= UVC_DT_HEADER_SIZE(1);
  	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -840,7 +840,7 @@ static int uvcg_streaming_header_allow_link(struct config_item *src,
 
  	format_ptr = kzalloc(sizeof(*format_ptr), GFP_KERNEL);
  	if (!format_ptr) {
-		ret = PTR_ERR(format_ptr);
+		ret = -ENOMEM;
  		goto out;
  	}
  	ret = 0;
@@ -960,7 +960,7 @@ static struct config_item
 
  	h = kzalloc(sizeof(*h), GFP_KERNEL);
  	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
  	INIT_LIST_HEAD(&h->formats);
  	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -1278,7 +1278,7 @@ static struct config_item *uvcg_frame_make(struct config_group *group,
 
  	h = kzalloc(sizeof(*h), GFP_KERNEL);
  	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
  	h->frame.b_descriptor_type		= USB_DT_CS_INTERFACE;
  	h->frame.b_frame_index			= 1;
@@ -1563,7 +1563,7 @@ static struct config_group *uvcg_uncompressed_make(struct config_group *group,
 
  	h = kzalloc(sizeof(*h), GFP_KERNEL);
  	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
  	h->desc.bLength			= UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
  	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -1772,7 +1772,7 @@ static struct config_group *uvcg_mjpeg_make(struct config_group *group,
 
  	h = kzalloc(sizeof(*h), GFP_KERNEL);
  	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
  	h->desc.bLength			= UVC_DT_FORMAT_MJPEG_SIZE;
  	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -2124,7 +2124,7 @@ static int uvcg_streaming_class_allow_link(struct config_item *src,
  	count += 2; /* color_matching, NULL */
  	*class_array = kcalloc(count, sizeof(void *), GFP_KERNEL);
  	if (!*class_array) {
-		ret = PTR_ERR(*class_array);
+		ret = -ENOMEM;
  		goto unlock;
  	}
 
--

To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Acked-by on v1 1/6
#2 lore raw
In reply to Dan Carpenter

Hi Dan,

Thank you for the patch.

Quoted 4 lines · On Wednesday 14 January 2015 23:59:48 Dan Carpenter wrote:

We're basically saying ERR_CAST(NULL) and PTR_ERR(NULL) here, which is nonsensical.

Quoted 71 lines
(quoted diff) +0 -0

b/drivers/usb/gadget/function/uvc_configfs.c index 33d92ab..d112c99 100644

drivers/usb/gadget/function/uvc_configfs.c +1 -1
@@ -148,7 +148,7 @@ static struct config_item
 *uvcg_control_header_make(struct config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->desc.bLength			= UVC_DT_HEADER_SIZE(1);
drivers/usb/gadget/function/uvc_configfs.c +1 -1
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -840,7 +840,7 @@ static int uvcg_streaming_header_allow_link(struct
 config_item *src,
 
 	format_ptr = kzalloc(sizeof(*format_ptr), GFP_KERNEL);
 	if (!format_ptr) {
-		ret = PTR_ERR(format_ptr);
+		ret = -ENOMEM;
 		goto out;
 	}
drivers/usb/gadget/function/uvc_configfs.c +2 -2
 	ret = 0;
@@ -960,7 +960,7 @@ static struct config_item
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	INIT_LIST_HEAD(&h->formats);
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -1278,7 +1278,7 @@ static struct config_item *uvcg_frame_make(struct
 config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->frame.b_descriptor_type		= USB_DT_CS_INTERFACE;
drivers/usb/gadget/function/uvc_configfs.c +1 -1
 	h->frame.b_frame_index			= 1;
@@ -1563,7 +1563,7 @@ static struct config_group
 *uvcg_uncompressed_make(struct config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->desc.bLength			= UVC_DT_FORMAT_UNCOMPRESSED_SIZE;
drivers/usb/gadget/function/uvc_configfs.c +1 -1
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -1772,7 +1772,7 @@ static struct config_group *uvcg_mjpeg_make(struct
 config_group *group,
 
 	h = kzalloc(sizeof(*h), GFP_KERNEL);
 	if (!h)
-		return ERR_CAST(h);
+		return ERR_PTR(-ENOMEM);
 
 	h->desc.bLength			= UVC_DT_FORMAT_MJPEG_SIZE;
drivers/usb/gadget/function/uvc_configfs.c +0 -0
 	h->desc.bDescriptorType		= USB_DT_CS_INTERFACE;
@@ -2124,7 +2124,7 @@ static int uvcg_streaming_class_allow_link(struct

config_item *src, count += 2; /* color_matching, NULL */

drivers/usb/gadget/function/uvc_configfs.c +1 -1
 	*class_array = kcalloc(count, sizeof(void *), GFP_KERNEL);
 	if (!*class_array) {
-		ret = PTR_ERR(*class_array);
+		ret = -ENOMEM;
 		goto unlock;
 	}
Signature · 3 lines
Regards,

Laurent Pinchart