From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755075AbdJINTv (ORCPT ); Mon, 9 Oct 2017 09:19:51 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43462 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755057AbdJINTs (ORCPT ); Mon, 9 Oct 2017 09:19:48 -0400 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Johan Hovold" , "Jarod Wilson" , "Mauro Carvalho Chehab" , "Sean Young" Date: Mon, 09 Oct 2017 13:30:34 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 05/74] [media] mceusb: fix memory leaks in error path In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.94-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 2d5a6ce71c72d98d4f7948672842e3e8c265a8b7 upstream. Fix urb and transfer-buffer leaks in an urb-submission error path which may be hit when a device is disconnected. Fixes: 66e89522aff7 ("V4L/DVB: IR: add mceusb IR receiver driver") Cc: Jarod Wilson Signed-off-by: Johan Hovold Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab [bwh: Backported to 3.2: - Add check on urb_type, as async_buf and async_urb aren't always allocated - Adjust context] Signed-off-by: Ben Hutchings --- --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -739,6 +739,7 @@ static void mce_request_packet(struct mc } else if (urb_type == MCEUSB_RX) { /* standard request */ async_urb = ir->urb_in; + async_buf = NULL; ir->send_flags = RECV_FLAG_IN_PROGRESS; } else { @@ -754,6 +755,10 @@ static void mce_request_packet(struct mc res = usb_submit_urb(async_urb, GFP_ATOMIC); if (res) { mce_dbg(dev, "receive request FAILED! (res=%d)\n", res); + if (urb_type == MCEUSB_TX) { + kfree(async_buf); + usb_free_urb(async_urb); + } return; } mce_dbg(dev, "receive request complete (res=%d)\n", res);