Skip to contentSkip to conversation

ViCam: Adjustments for vicam_dostream()

PATCH New SF Markus Elfring 1 participant 3 messages Sep 18, 2017

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

cover ViCam: Adjustments for vicam_dostream()

From: Markus Elfring <[email protected]>
Date: Mon, 18 Sep 2017 22:05:22 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an error message for a failed memory allocation Return directly after a failed kmalloc()

 drivers/media/usb/gspca/vicam.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/2 vicam: Delete an error message for a failed memory allocation in vicam_dostream()

From: Markus Elfring <[email protected]>
Date: Mon, 18 Sep 2017 21:48:55 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/media/usb/gspca/vicam.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/usb/gspca/vicam.c +1 -3
index 554b90ef2200..15b6887a8e97 100644
@@ -183,10 +183,8 @@ static void vicam_dostream(struct work_struct *work)
 	frame_sz = gspca_dev->cam.cam_mode[gspca_dev->curr_mode].sizeimage +
 		   HEADER_SIZE;
 	buffer = kmalloc(frame_sz, GFP_KERNEL | GFP_DMA);
-	if (!buffer) {
-		pr_err("Couldn't allocate USB buffer\n");
+	if (!buffer)
 		goto exit;
-	}
 
 	while (gspca_dev->present && gspca_dev->streaming) {
 #ifdef CONFIG_PM
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/2 vicam: Return directly after a failed kmalloc() in vicam_dostream()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 18 Sep 2017 21:56:55 +0200

* Return directly after a call of the function "kmalloc" failed at the beginning.

* Delete the jump target "exit" which became unnecessary with this refactoring.

---
 drivers/media/usb/gspca/vicam.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/gspca/vicam.c +2 -2
index 15b6887a8e97..11508ab283cd 100644
@@ -184,7 +184,7 @@ static void vicam_dostream(struct work_struct *work)
 		   HEADER_SIZE;
 	buffer = kmalloc(frame_sz, GFP_KERNEL | GFP_DMA);
 	if (!buffer)
-		goto exit;
+		return;
 
 	while (gspca_dev->present && gspca_dev->streaming) {
 #ifdef CONFIG_PM
@@ -205,7 +205,7 @@ static void vicam_dostream(struct work_struct *work)
 				frame_sz - HEADER_SIZE);
 		gspca_frame_add(gspca_dev, LAST_PACKET, NULL, 0);
 	}
-exit:
+
 	kfree(buffer);
 }
 
Signature · 1 line
2.14.1