summaryrefslogtreecommitdiff
path: root/sys/dev/usb/uvideo.c
diff options
context:
space:
mode:
authorMichael Knudsen <mk@cvs.openbsd.org>2011-06-17 07:06:48 +0000
committerMichael Knudsen <mk@cvs.openbsd.org>2011-06-17 07:06:48 +0000
commit588580a3636f1d2f89071c40a24811393a93accc (patch)
treefe14f36309c4c36297658840fbee97ea66114ab6 /sys/dev/usb/uvideo.c
parentf54f5c33e3808aca4c742c69b64f7a9619f240cb (diff)
M_WAITOK cleanup of two cases:
1) Allocating with M_WAITOK, checking for NULL, and calling panic() is pointless (malloc() will panic if it can't allocate) so remove the check and the call. 2) Allocating with M_WAITOK, checking for NULL, and then gracefully handling failure to allocate is pointless. Instead also pass M_CANFAIL so malloc() doesn't panic so we can actually handle it gracefully. 1) was done using Coccinelle. Input from oga. ok miod.
Diffstat (limited to 'sys/dev/usb/uvideo.c')
-rw-r--r--sys/dev/usb/uvideo.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c
index 2e9712de891..3cbe0c76a84 100644
--- a/sys/dev/usb/uvideo.c
+++ b/sys/dev/usb/uvideo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvideo.c,v 1.161 2011/04/11 02:04:48 jakemsr Exp $ */
+/* $OpenBSD: uvideo.c,v 1.162 2011/06/17 07:06:47 mk Exp $ */
/*
* Copyright (c) 2008 Robert Nagy <robert@openbsd.org>
@@ -3242,7 +3242,7 @@ uvideo_queryctrl(void *v, struct v4l2_queryctrl *qctrl)
return (EINVAL);
}
- ctrl_data = malloc(ctrl_len, M_USBDEV, M_WAITOK);
+ ctrl_data = malloc(ctrl_len, M_USBDEV, M_WAITOK | M_CANFAIL);
if (ctrl_data == NULL) {
printf("%s: could not allocate control data\n", __func__);
return (ENOMEM);
@@ -3357,7 +3357,7 @@ uvideo_g_ctrl(void *v, struct v4l2_control *gctrl)
return (EINVAL);
}
- ctrl_data = malloc(ctrl_len, M_USBDEV, M_WAITOK);
+ ctrl_data = malloc(ctrl_len, M_USBDEV, M_WAITOK | M_CANFAIL);
if (ctrl_data == NULL) {
printf("%s: could not allocate control data\n", __func__);
return (ENOMEM);
@@ -3405,7 +3405,7 @@ uvideo_s_ctrl(void *v, struct v4l2_control *sctrl)
return (EINVAL);
}
- ctrl_data = malloc(ctrl_len, M_USBDEV, M_WAITOK);
+ ctrl_data = malloc(ctrl_len, M_USBDEV, M_WAITOK | M_CANFAIL);
if (ctrl_data == NULL) {
printf("%s: could not allocate control data\n", __func__);
return (ENOMEM);