From patchwork Wed May 5 06:01:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 3305 Return-path: Envelope-to: mchehab@infradead.org Delivery-date: Wed, 05 May 2010 06:01:41 +0000 Received: from bombadil.infradead.org [18.85.46.34] by pedra with IMAP (fetchmail-6.3.6) for (single-drop); Wed, 05 May 2010 03:04:29 -0300 (BRT) Received: from vger.kernel.org ([209.132.180.67]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1O9Xfx-0001Ns-Ba; Wed, 05 May 2010 06:01:41 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755447Ab0EEGBk (ORCPT + 1 other); Wed, 5 May 2010 02:01:40 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:60929 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755382Ab0EEGBi (ORCPT ); Wed, 5 May 2010 02:01:38 -0400 Received: by fxm10 with SMTP id 10so3901101fxm.19 for ; Tue, 04 May 2010 23:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=L3jll+MuDIV6Zv1T5rzuH7AV/95Cu+1cW3faKqpr0VA=; b=QZ4kEJkZ10F0SCJaiB4QIHQzaBv41BeNMFtXtZ/S8Ibhi1KfZgdpgFLfacELkZmqNw szRMGomahehxbUxdqzkwb1JopAJ10i75dm+IQk7wDAfMtvU+tYWINnx5WnuTuQ5ZoICH bcoQzfGribw2pBM1AHtiAx3cUscZ5E9VmLs5g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=jrgOLR9OSu34LkAbem9bPJzmmaied9pPRT07CGojAN4+OoGymVTcWqVOMJziJuknGK tQCeMFBVTLuKPpvIDe5+MaOURfzrCo+DkXxJUjVBxqC1Dx5w1tmRizZSiflBujYIH3e7 xCLo1P0anikxi6HeptnA7mWkwJJj9NWZjsOxQ= Received: by 10.223.51.152 with SMTP id d24mr4974444fag.36.1273039296949; Tue, 04 May 2010 23:01:36 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id 1sm12845652fks.24.2010.05.04.23.01.34 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 May 2010 23:01:36 -0700 (PDT) Date: Wed, 5 May 2010 08:01:30 +0200 From: Dan Carpenter To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab Subject: [patch -next 1/2] media/s2255drv: return if vdev not found Message-ID: <20100505060130.GG27064@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The original code didn't handle the case where vdev was not found so I added a check for that. Signed-off-by: Dan Carpenter --- 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/s2255drv.c b/drivers/media/video/s2255drv.c index ac9c40c..1f9a49e 100644 --- a/drivers/media/video/s2255drv.c +++ b/drivers/media/video/s2255drv.c @@ -1716,11 +1716,15 @@ static int s2255_open(struct file *file) dprintk(1, "s2255: open called (dev=%s)\n", video_device_node_name(vdev)); - for (i = 0; i < MAX_CHANNELS; i++) + for (i = 0; i < MAX_CHANNELS; i++) { if (&dev->vdev[i] == vdev) { cur_channel = i; break; } + } + if (i == MAX_CHANNELS) + return -ENODEV; + /* * open lock necessary to prevent multiple instances * of v4l-conf (or other programs) from simultaneously