From patchwork Tue Jan 7 13:55:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda Delgado X-Patchwork-Id: 3448251 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B6A7AC02DC for ; Tue, 7 Jan 2014 13:55:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A442420109 for ; Tue, 7 Jan 2014 13:55:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 88BA5200F0 for ; Tue, 7 Jan 2014 13:55:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752196AbaAGNzt (ORCPT ); Tue, 7 Jan 2014 08:55:49 -0500 Received: from mail-la0-f53.google.com ([209.85.215.53]:53087 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbaAGNzt (ORCPT ); Tue, 7 Jan 2014 08:55:49 -0500 Received: by mail-la0-f53.google.com with SMTP id mc6so124316lab.26 for ; Tue, 07 Jan 2014 05:55:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=uMbfSqg9yUs/PAzHVrajBdMg73afZ/YiAU0wNRdQQGk=; b=0MJACSJwQXA/Oy+XJeDzzGfJZ8whDBlSxWbxYd+AMxhzB97JBlke3so+VBzd/XdbZp te0jDJpQ6Ct4+1NSccBPXxTyjhV5m/nhfO9EpMV9Sywg2DUq07+lKduHc+YS4ltymSCa YFtWd/6gZYl9lkvxex0bT9+Vsu/KrCUNnDnauaA9CRTZ420+/xDDT9TxCrqKw/UjZr/h Th1HuRAhRkk0K7ct9un47cPF4GAFF8TO6PBpLOoC8ed/fyI25t9YvnJgoAF7LczBQQFy GFyDvJUuoGsfIcoUR9vpWqCZ7JOLDWVAtYwZcZ/Yiso0QPcP2/yKbYvTeYgVm/O9FK09 blew== X-Received: by 10.112.181.232 with SMTP id dz8mr44414264lbc.8.1389102947401; Tue, 07 Jan 2014 05:55:47 -0800 (PST) Received: from neopili.qtec.com (0x4dd4aed9.adsl.cybercity.dk. [77.212.174.217]) by mx.google.com with ESMTPSA id mx3sm44971222lbc.14.2014.01.07.05.55.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jan 2014 05:55:46 -0800 (PST) From: Ricardo Ribalda Delgado To: Hans Verkuil , Pawel Osciak , Marek Szyprowski , Kyungmin Park , Mauro Carvalho Chehab , linux-media@vger.kernel.org (open list:VIDEOBUF2 FRAMEWORK), linux-kernel@vger.kernel.org (open list) Cc: Ricardo Ribalda Delgado Subject: [PATCH] vb2: Check if there are buffers before streamon Date: Tue, 7 Jan 2014 14:55:35 +0100 Message-Id: <1389102935-4266-1-git-send-email-ricardo.ribalda@gmail.com> X-Mailer: git-send-email 1.8.5.2 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a test preventing streamon() if there is no buffer ready. Without this patch, a user could call streamon() before preparing any buffer. This leads to a situation where if he calls close() before calling streamoff() the device is kept streaming. Signed-off-by: Ricardo Ribalda Delgado --- drivers/media/v4l2-core/videobuf2-core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 098df28..6f20e5a 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1776,6 +1776,11 @@ static int vb2_internal_streamon(struct vb2_queue *q, enum v4l2_buf_type type) return 0; } + if (!q->num_buffers) { + dprintk(1, "streamon: no frames have been requested\n"); + return -EINVAL; + } + /* * If any buffers were queued before streamon, * we can now pass them to driver for processing.