* [PATCH 0/2] [media] ViCam: Adjustments for vicam_dostream()
@ 2017-09-18 20:10 SF Markus Elfring
2017-09-18 20:11 ` [PATCH 1/2] [media] vicam: Delete an error message for a failed memory allocation in vicam_dostream() SF Markus Elfring
2017-09-18 20:12 ` [PATCH 2/2] [media] vicam: Return directly after a failed kmalloc() " SF Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-09-18 20:10 UTC (permalink / raw)
To: linux-media, Hans Verkuil, Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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(-)
--
2.14.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] [media] vicam: Delete an error message for a failed memory allocation in vicam_dostream()
2017-09-18 20:10 [PATCH 0/2] [media] ViCam: Adjustments for vicam_dostream() SF Markus Elfring
@ 2017-09-18 20:11 ` SF Markus Elfring
2017-09-18 20:12 ` [PATCH 2/2] [media] vicam: Return directly after a failed kmalloc() " SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-09-18 20:11 UTC (permalink / raw)
To: linux-media, Hans Verkuil, Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/gspca/vicam.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/media/usb/gspca/vicam.c b/drivers/media/usb/gspca/vicam.c
index 554b90ef2200..15b6887a8e97 100644
--- a/drivers/media/usb/gspca/vicam.c
+++ b/drivers/media/usb/gspca/vicam.c
@@ -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
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] [media] vicam: Return directly after a failed kmalloc() in vicam_dostream()
2017-09-18 20:10 [PATCH 0/2] [media] ViCam: Adjustments for vicam_dostream() SF Markus Elfring
2017-09-18 20:11 ` [PATCH 1/2] [media] vicam: Delete an error message for a failed memory allocation in vicam_dostream() SF Markus Elfring
@ 2017-09-18 20:12 ` SF Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: SF Markus Elfring @ 2017-09-18 20:12 UTC (permalink / raw)
To: linux-media, Hans Verkuil, Mauro Carvalho Chehab, Sakari Ailus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/usb/gspca/vicam.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/gspca/vicam.c b/drivers/media/usb/gspca/vicam.c
index 15b6887a8e97..11508ab283cd 100644
--- a/drivers/media/usb/gspca/vicam.c
+++ b/drivers/media/usb/gspca/vicam.c
@@ -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);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-09-18 20:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-18 20:10 [PATCH 0/2] [media] ViCam: Adjustments for vicam_dostream() SF Markus Elfring
2017-09-18 20:11 ` [PATCH 1/2] [media] vicam: Delete an error message for a failed memory allocation in vicam_dostream() SF Markus Elfring
2017-09-18 20:12 ` [PATCH 2/2] [media] vicam: Return directly after a failed kmalloc() " SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).