From patchwork Tue Oct 23 21:26:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 10653687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2FD913A4 for ; Tue, 23 Oct 2018 21:27:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE76329EC1 for ; Tue, 23 Oct 2018 21:27:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B152029EE3; Tue, 23 Oct 2018 21:27:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 592C529EC1 for ; Tue, 23 Oct 2018 21:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728808AbeJXFwO (ORCPT ); Wed, 24 Oct 2018 01:52:14 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39456 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728426AbeJXFwO (ORCPT ); Wed, 24 Oct 2018 01:52:14 -0400 Received: by mail-wm1-f66.google.com with SMTP id y144-v6so3255772wmd.4; Tue, 23 Oct 2018 14:27:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=hXi4nMThHrEap0BgiQYjva6K956YpZmWDE55oKXgYxI=; b=XxUd2HSVH77CmD5zIrG6XJozKa8+00ehbsqR72vYOT2PQWkPzsQErV7oWuHuxfiQM4 iMduCumrlAgdibH4Lbd6vx3MF0zq2LPWfEWABz44vyJ6vo/XecYHKNCDopK5IA+SC7iw 7M1I+fX1qWkeKxGxSmw+WU+VaoyFe6vAaUM4ahFzD4GmJU6WsCFwJLbkQKZMkTimWKw6 wjYX1FYw0iZSLAac9jVjtxymK0T/7nApbX7qBEUhBctvj8k7a8+utEY5KEyaCmEf2Ge2 VPw5dNshZEIoSKFs4Ga6Q+hBfHuGW2/8o/+D0FK4JHUctFsSKofBbXAghYcso1QESVif Dxyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=hXi4nMThHrEap0BgiQYjva6K956YpZmWDE55oKXgYxI=; b=eU7oMEZKRJxmf5rZ6PhAAvQsB1guDfHShaaVuwJGA5S4Gr+zsJ6RvqWlexxjdex/W2 spyXZam24GOgHRhKo7QPT+KeP8AGJRPBKGnj80MQiljPx9ymX4yNZZR57CfUuNirwpQk JefNKupBtkvk8B7gjmEROHsBtvpx1DG8Fje/AXMvEb7cssbJcrnFdgOcPNKOy/oSV1F+ Ysbh5SuamghrLXuyNOjyWJV52+ODCwDLpNU8Sa8r94gBNMyg7SqTwV7mNh3W2mKmvX1F h0FkJdq6aQI7EFIEVq9YovV56Kitv9nQ1bFJlgI8xQ82R835T9b41yxpYFFoxtLk81Ee 3zog== X-Gm-Message-State: ABuFfohlCU7OA65Hj0QVhPo1UmVWtDoKwBCnQbY0BajIAZvrobs9pVEn d3evC3ZkM04tgFif3oi9NPOV26mF X-Google-Smtp-Source: ACcGV625uSW22ZMCkmHop6PZMnnKXb7Ny4IyTKmahahjDbxOZB4hRSmYc/2ZNaWHqkqFp333VSZY8g== X-Received: by 2002:a1c:f003:: with SMTP id a3-v6mr22165254wmb.50.1540330022494; Tue, 23 Oct 2018 14:27:02 -0700 (PDT) Received: from [192.168.43.227] (92.40.249.41.threembb.co.uk. [92.40.249.41]) by smtp.gmail.com with ESMTPSA id c14-v6sm4566088wmh.44.2018.10.23.14.27.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Oct 2018 14:27:01 -0700 (PDT) To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Antti Palosaari , stable@vger.kernel.org From: Malcolm Priestley Subject: [PATCH] [bug/urgent] dvb-usb-v2: Fix incorrect use of transfer_flags URB_FREE_BUFFER Message-ID: <04c2de66-ec7f-48db-472b-bdc4cd266cc8@gmail.com> Date: Tue, 23 Oct 2018 22:26:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In commit 1a0c10ed7b media: dvb-usb-v2: stop using coherent memory for URBs incorrectly adds URB_FREE_BUFFER after every urb transfer resulting in no buffers and eventually deadlock. The stream buffer should remain in constant while in use by user and kfree() on their departure. Signed-off-by: Malcolm Priestley CC: stable@vger.kernel.org # v4.18+ --- drivers/media/usb/dvb-usb-v2/usb_urb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) return 0; @@ -186,7 +185,7 @@ static int usb_urb_alloc_isoc_urbs(struct usb_data_stream *stream) urb->complete = usb_urb_complete; urb->pipe = usb_rcvisocpipe(stream->udev, stream->props.endpoint); - urb->transfer_flags = URB_ISO_ASAP | URB_FREE_BUFFER; + urb->transfer_flags = URB_ISO_ASAP; urb->interval = stream->props.u.isoc.interval; urb->number_of_packets = stream->props.u.isoc.framesperurb; urb->transfer_buffer_length = stream->props.u.isoc.framesize * @@ -210,7 +209,7 @@ static int usb_free_stream_buffers(struct usb_data_stream *stream) if (stream->state & USB_STATE_URB_BUF) { while (stream->buf_num) { stream->buf_num--; - stream->buf_list[stream->buf_num] = NULL; + kfree(stream->buf_list[stream->buf_num]); } } diff --git a/drivers/media/usb/dvb-usb-v2/usb_urb.c b/drivers/media/usb/dvb-usb-v2/usb_urb.c index 024c751eb165..2ad2ddeaff51 100644 --- a/drivers/media/usb/dvb-usb-v2/usb_urb.c +++ b/drivers/media/usb/dvb-usb-v2/usb_urb.c @@ -155,7 +155,6 @@ static int usb_urb_alloc_bulk_urbs(struct usb_data_stream *stream) stream->props.u.bulk.buffersize, usb_urb_complete, stream); - stream->urb_list[i]->transfer_flags = URB_FREE_BUFFER; stream->urbs_initialized++; }