From patchwork Wed Oct 24 20:05:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Malcolm Priestley X-Patchwork-Id: 10655015 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 0FD6213B5 for ; Wed, 24 Oct 2018 20:05:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9EC628A34 for ; Wed, 24 Oct 2018 20:05:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7BD72B227; Wed, 24 Oct 2018 20:05:48 +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 78D9B28A34 for ; Wed, 24 Oct 2018 20:05:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725817AbeJYEfO (ORCPT ); Thu, 25 Oct 2018 00:35:14 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46082 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725778AbeJYEfO (ORCPT ); Thu, 25 Oct 2018 00:35:14 -0400 Received: by mail-wr1-f68.google.com with SMTP id i4-v6so6874796wrr.13; Wed, 24 Oct 2018 13:05:46 -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=iss+Hg3LCPa6YDA9roF4YTOE5eusAqt6lKCTcTzGzqs=; b=mmq0TDdTIzWjvISidFJUTyIkAFuOnhsEWaqGCacI9GA/1T3IEzBYy+c/412QfHNvGp 1MCUC8B90D6ID7LWhABHgoIvoLaSVkFG0RzAyPK1iZJdQ7vcDI2QiJ32jOVTTJTkwzNI ennGtgZBR8vIYQJCzWbCk9B3r6uPnL3l+vq6f2rcKXAC1721ePb3vuYjXpJa+jEFVlxm yxa0JIP7M3a8xAyrfi1fDmAM5AG/DhO+vGPchCnuqmW+umFuQhEx0569VY+2J+CuHe7j WhcTMGsqkzdgQ2Cij5VCBD6o72/Qt0UwV2iCmLrCGqniW0Xs4Rz7jcL6ilp9QPxb805y p3Gw== 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=iss+Hg3LCPa6YDA9roF4YTOE5eusAqt6lKCTcTzGzqs=; b=ZXOWWnSrE3oemjgDaqPADfc79RH0BAPR348rJUbdBRgmzBI4O3FXIUtAHFqRoS12wr DfEvDAukqieD2GF1JmCu8ezj9BVjUcY4/1jEtCTvleGm5aFTvsMLNMGtROXPJ67qANTV U/rUtzehfx078/gZcBYMyckC4WSS3gYKDHSAirHbOq+zF/ybJRmHYBjrap78Q1TCykRX 1QiAT554asgG7GuVKiFUieh4Hm0XNqagSSfvtJ6HJpGSzoDP6UKrDGRJ/1vAEKTkDh9N BDy7OOAP2qkB7SWz+BO4PE3plfBqCuKiUaltkXVJWNsURt/88S65nbyjWGrvIh1vsIlx iWKw== X-Gm-Message-State: AGRZ1gLshEwGlji1dsoWnkYHXK8BpiuodiGwV1Md258S25IvfJkPZRSH yrnelobQvxNsk6NB4MpyOwj/iTU7 X-Google-Smtp-Source: AJdET5e8wjMH2f991Lur0UeP3EHFawvXyshxvzY88AfbX6KJMaQ/jSffDQierOWqoyOc6mc5YfLBKw== X-Received: by 2002:adf:e348:: with SMTP id n8-v6mr1161723wrj.158.1540411545625; Wed, 24 Oct 2018 13:05:45 -0700 (PDT) Received: from [192.168.43.227] (94.197.121.93.threembb.co.uk. [94.197.121.93]) by smtp.gmail.com with ESMTPSA id r134-v6sm3222508wmg.9.2018.10.24.13.05.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 13:05:44 -0700 (PDT) To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Antti Palosaari , stable@vger.kernel.org From: Malcolm Priestley Subject: [PATCH v2] [bug/urgent] dvb-usb-v2: Fix incorrect use of transfer_flags URB_FREE_BUFFER Message-ID: Date: Wed, 24 Oct 2018 21:05:43 +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 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(-) 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++; } 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]); } }