Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4534908imm; Mon, 17 Sep 2018 16:02:52 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdak1eFk0xyVAKWhiEdXRlWwzXECpjC4dOgZSyzMGmXpCdSH+QtLH+sm0kPVr6BgpnVlnz2R X-Received: by 2002:a17:902:464:: with SMTP id 91-v6mr27043028ple.125.1537225372909; Mon, 17 Sep 2018 16:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225372; cv=none; d=google.com; s=arc-20160816; b=RFHH/xL9OpHwlsKbBHIgkDzKZrdIqdHHwHbJkb7/KuH0fMnAZWNQbvigb7uGs6iDu2 hModpvmf6Ya2/PwuA6qeIRZ88ypyPW/HOe47x/Mif0l/usIRTf+yeGSP+TSGLoYStuHI oWsQgpNJQFwzQY417kvr+Ak67biHQZCg/FF+i1QuBEacsbXkEwHIhKjIo+bCyghUZnke MzkPwzn4OtxjyZtUoL5HhkYJbt4KEr6SewgwkE7jm708gvvH0liPk70rOhAQQpD8iBOc fYgY2se2VCP4r4AXgj9B120q0qQVI7BDtCLJKpK8F+jwWh1BbIO8JwHoqhwofo9eYXMK n4fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=H3lL4hg9sL7GTjmsOguDB3MAwU1tmS8AA7ovbuz5QhE=; b=nxy3Ibl8cFS0Wa/DFndKjOKQTu9yWDpU/x2G7WNneEWgLrREQLzQaChKLD6u9OORw1 tJdLI5RmTyQ95+9iEFrZhpMi7JCp/iH9KJwOU3jo/mFDZGDpKQC0BnLpQqH1ueeJ7Gj0 6ettG630p9DE4jiICiGPc/bzmsKI0jFX9fAq1k7Awukyj2vxTUX7XZirCRDNcHU29jG6 7RyhVVXXHbgZv3zA+tcs4ywJHqr/f8CQ4PakMpjvEjLKfcZtRrrfnrFTFN/aLHtSEtqL 5mEcOWo0o0o+65Re21h1ntNO2Omawn0KaE3SJFT35V1uJZd4KxJAcbc+G3unbAOa2Onl 9pSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3-v6si16897886plc.502.2018.09.17.16.02.37; Mon, 17 Sep 2018 16:02:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730137AbeIREaf (ORCPT + 99 others); Tue, 18 Sep 2018 00:30:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48206 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729660AbeIREae (ORCPT ); Tue, 18 Sep 2018 00:30:34 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 795D2C77; Mon, 17 Sep 2018 23:01:06 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Vasilyev , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 030/126] media: dw2102: Fix memleak on sequence of probes Date: Tue, 18 Sep 2018 00:41:18 +0200 Message-Id: <20180917211706.765606744@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Anton Vasilyev [ Upstream commit 299c7007e93645067e1d2743f4e50156de78c4ff ] Each call to dw2102_probe() allocates memory by kmemdup for structures p1100, s660, p7500 and s421, but there is no their deallocation. dvb_usb_device_init() copies the corresponding structure into dvb_usb_device->props, so there is no use of original structure after dvb_usb_device_init(). The patch moves structures from global scope to local and adds their deallocation. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Anton Vasilyev Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/dvb-usb/dw2102.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) --- a/drivers/media/usb/dvb-usb/dw2102.c +++ b/drivers/media/usb/dvb-usb/dw2102.c @@ -2103,14 +2103,12 @@ static struct dvb_usb_device_properties } }; -static struct dvb_usb_device_properties *p1100; static const struct dvb_usb_device_description d1100 = { "Prof 1100 USB ", {&dw2102_table[PROF_1100], NULL}, {NULL}, }; -static struct dvb_usb_device_properties *s660; static const struct dvb_usb_device_description d660 = { "TeVii S660 USB", {&dw2102_table[TEVII_S660], NULL}, @@ -2129,14 +2127,12 @@ static const struct dvb_usb_device_descr {NULL}, }; -static struct dvb_usb_device_properties *p7500; static const struct dvb_usb_device_description d7500 = { "Prof 7500 USB DVB-S2", {&dw2102_table[PROF_7500], NULL}, {NULL}, }; -static struct dvb_usb_device_properties *s421; static const struct dvb_usb_device_description d421 = { "TeVii S421 PCI", {&dw2102_table[TEVII_S421], NULL}, @@ -2336,6 +2332,11 @@ static int dw2102_probe(struct usb_inter const struct usb_device_id *id) { int retval = -ENOMEM; + struct dvb_usb_device_properties *p1100; + struct dvb_usb_device_properties *s660; + struct dvb_usb_device_properties *p7500; + struct dvb_usb_device_properties *s421; + p1100 = kmemdup(&s6x0_properties, sizeof(struct dvb_usb_device_properties), GFP_KERNEL); if (!p1100) @@ -2404,8 +2405,16 @@ static int dw2102_probe(struct usb_inter 0 == dvb_usb_device_init(intf, &t220_properties, THIS_MODULE, NULL, adapter_nr) || 0 == dvb_usb_device_init(intf, &tt_s2_4600_properties, - THIS_MODULE, NULL, adapter_nr)) + THIS_MODULE, NULL, adapter_nr)) { + + /* clean up copied properties */ + kfree(s421); + kfree(p7500); + kfree(s660); + kfree(p1100); + return 0; + } retval = -ENODEV; kfree(s421);