From patchwork Sat Sep 19 01:13:37 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roel Kluin X-Patchwork-Id: 48710 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8J16Thq003826 for ; Sat, 19 Sep 2009 01:06:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752894AbZISBGX (ORCPT ); Fri, 18 Sep 2009 21:06:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752866AbZISBGX (ORCPT ); Fri, 18 Sep 2009 21:06:23 -0400 Received: from mail-ew0-f206.google.com ([209.85.219.206]:42465 "EHLO mail-ew0-f206.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752894AbZISBGW (ORCPT ); Fri, 18 Sep 2009 21:06:22 -0400 Received: by ewy2 with SMTP id 2so1774105ewy.17 for ; Fri, 18 Sep 2009 18:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:content-type :content-transfer-encoding; bh=1ZgBes7oQxVKYAi8g1wZewX9EboFQoT5d9KEsmIlqSo=; b=naCPetz70+lJkBdic/Bys5chDeV2yiK+FSuEIloPv0Gin3Iu9fqcsEwTCfxI5fn1CY nE+jIOCXoQJFpuU9S2Oe5QVn0ESinFtkLbFdBGB6J2FiFSUh/kwKsq7tBVIuPDci5ts2 dtVyJUqfJMpzZW582h/G0RTYlsQvT/A2R4SNc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=a+4qH4kZwRM6JqNJnISFmUEEPHHMzUkg1fKXU/PPElG/kB+NPQS1y0i1QLOpYgpSK5 bupBh+TDorwb8Ta7t4Su/vTt8U5cLEZ5jv7Rco3ArCbCzvYa+jbfxyYkomOP4hEdlYfL J3lzHs6qF9NE3Q7C84ksnx52cPpTY+7Bm4F0w= Received: by 10.211.159.3 with SMTP id l3mr227636ebo.37.1253322385115; Fri, 18 Sep 2009 18:06:25 -0700 (PDT) Received: from zoinx.mars (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id 24sm2181616eyx.47.2009.09.18.18.06.24 (version=SSLv3 cipher=RC4-MD5); Fri, 18 Sep 2009 18:06:24 -0700 (PDT) Message-ID: <4AB43041.6050001@gmail.com> Date: Sat, 19 Sep 2009 03:13:37 +0200 From: Roel Kluin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Thunderbird/3.0b3 MIME-Version: 1.0 To: Laurent Pinchart , linux-uvc-devel@lists.berlios.de, linux-media@vger.kernel.org, Andrew Morton Subject: [PATCH] uvc: kmalloc failure ignored in uvc_ctrl_add_ctrl() Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Produce an error if kmalloc() fails. Signed-off-by: Roel Kluin --- Found with sed: http://kernelnewbies.org/roelkluin Build tested. Please review -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/video/uvc/uvc_ctrl.c b/drivers/media/video/uvc/uvc_ctrl.c index c3225a5..dda80b5 100644 --- a/drivers/media/video/uvc/uvc_ctrl.c +++ b/drivers/media/video/uvc/uvc_ctrl.c @@ -1189,7 +1189,7 @@ int uvc_ctrl_resume_device(struct uvc_device *dev) * Control and mapping handling */ -static void uvc_ctrl_add_ctrl(struct uvc_device *dev, +static int uvc_ctrl_add_ctrl(struct uvc_device *dev, struct uvc_control_info *info) { struct uvc_entity *entity; @@ -1214,7 +1214,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev, } if (!found) - return; + return 0; if (UVC_ENTITY_TYPE(entity) == UVC_VC_EXTENSION_UNIT) { /* Check if the device control information and length match @@ -1231,7 +1231,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev, "control " UVC_GUID_FORMAT "/%u (%d).\n", UVC_GUID_ARGS(info->entity), info->selector, ret); - return; + return -EINVAL; } if (info->size != le16_to_cpu(size)) { @@ -1239,7 +1239,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev, "/%u size doesn't match user supplied " "value.\n", UVC_GUID_ARGS(info->entity), info->selector); - return; + return -EINVAL; } ret = uvc_query_ctrl(dev, UVC_GET_INFO, ctrl->entity->id, @@ -1249,7 +1249,7 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev, "control " UVC_GUID_FORMAT "/%u (%d).\n", UVC_GUID_ARGS(info->entity), info->selector, ret); - return; + return -EINVAL; } flags = info->flags; @@ -1259,15 +1259,18 @@ static void uvc_ctrl_add_ctrl(struct uvc_device *dev, UVC_GUID_FORMAT "/%u flags don't match " "supported operations.\n", UVC_GUID_ARGS(info->entity), info->selector); - return; + return -EINVAL; } } ctrl->info = info; ctrl->data = kmalloc(ctrl->info->size * UVC_CTRL_NDATA, GFP_KERNEL); + if (ctrl->data == NULL) + return -ENOMEM; uvc_trace(UVC_TRACE_CONTROL, "Added control " UVC_GUID_FORMAT "/%u " "to device %s entity %u\n", UVC_GUID_ARGS(ctrl->info->entity), ctrl->info->selector, dev->udev->devpath, entity->id); + return 0; } /* @@ -1309,8 +1312,11 @@ int uvc_ctrl_add_info(struct uvc_control_info *info) } } - list_for_each_entry(dev, &uvc_driver.devices, list) - uvc_ctrl_add_ctrl(dev, info); + list_for_each_entry(dev, &uvc_driver.devices, list) { + ret = uvc_ctrl_add_ctrl(dev, info); + if (ret == -ENOMEM) + goto end; + } INIT_LIST_HEAD(&info->mappings); list_add_tail(&info->list, &uvc_driver.controls);