Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp5458629pxu; Tue, 22 Dec 2020 18:41:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOoo2wuAl+7EiGrABv0VcxzHoNxAaND07ryGx6CvjEQownDh+ZLTI7OrYvq8ys3Oo1RQns X-Received: by 2002:a17:906:cf81:: with SMTP id um1mr22762982ejb.122.1608691298509; Tue, 22 Dec 2020 18:41:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608691298; cv=none; d=google.com; s=arc-20160816; b=uavobs3kI3eox6xZHHxdGJtTMBZObV7lBT5pT95/xOxyqW5bu3GpY5Ub6aTx7I2AS9 C/RqhaS5mQ7CrPAdbsaM0FkLmm0uliyoe12yPfazCdyXgFURvHLWgw2XOrCycAivEdIp TfC2tMz/mM/UBAC52c5cXJ6O0SWRmXIks4iy7xprFfTDLlHh2sXeUXxVuj7sJEP8O8QD giJftpUrLqLcBX1xZIeH3W+i6cNvXJY58Iln++1Hv6qc7G1LlKwbjxbZf4ly4pDVQOPs eNZghWI4stDO1q9RtmC4176aeqGdBfczJ5V7MwL5eumNjjZ91MWrg1HehHjelUm2VsbY FnUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ypu9Ps2wS6Jj1TGmKc9JZjlrNL6XDHMMLyOF+ePiiPU=; b=z6+dJN/osYjDGIO7+xW9LQ1zZDF19l82MYSvySmly5Cei2myQiMNyiX8g2Y/dxjigH C2vivMmpXGlg1qivptwmouY2Sozk/PxN7O0kX8Wo84s1bWmaTfwDUSJHfABM8sz4/WRX Ri6NePNGA9cX9tTaI1Me1VnZ5hWb3toZj20Q9kll4qhDs0056QjMCuvryuuzRNyAjuYH o1YgcW7Le0SHe8H0ToBAVF8K1W4/AEFrO7FEsJY7kmYqWTUHeOxL1lX3/v95wc5R+zUv NDUxKKHz/GmcsbVQ0manH6T+WzR03ukle0bd/iX//dhj2AV30PahAs2lc95ctF/DOD27 G4Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BoCd8qHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si10770687ejj.456.2020.12.22.18.41.16; Tue, 22 Dec 2020 18:41:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BoCd8qHz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730135AbgLWCkC (ORCPT + 99 others); Tue, 22 Dec 2020 21:40:02 -0500 Received: from mail.kernel.org ([198.145.29.99]:52758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728174AbgLWCXl (ORCPT ); Tue, 22 Dec 2020 21:23:41 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3CFB2222D; Wed, 23 Dec 2020 02:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608690205; bh=jnVDOmEeGyU9l9N9TYOqlwQedoGghCb0HUwCnNEMQak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BoCd8qHzZyzCTyHMCNEPtVZdATGYlWAJ0TLVMDnnXYOqwmewBOLaaqawGTpujtI16 fI+RIPLJV74Q2PvZ6zgr1mnEwojiVW/W50M27afwGcv10IPGj81/2dZ5OKbvgivxH3 2zqCBeo3Ux3Ne3gxzeEvd/BhRVpGvJPwwPT7pu7bcO9YR71s3lMn1YAaTsy2fMHC+V MvMa7do7NI2WzXP3+EGocdXHvMgiY2EMuSQM1YavuDVhiGtXuDo+RvA4dAgXwSVf91 v+975YS1Pk5+fztA4B+Hv/zuGDQHGsK8nSFs36duNSfd9S11Ur4ZV58R5NNFmQcvAw 5QiQ+AYa65f3g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dinghao Liu , Sean Young , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 26/66] media: dvbdev: Fix memleak in dvb_register_device Date: Tue, 22 Dec 2020 21:22:12 -0500 Message-Id: <20201223022253.2793452-26-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201223022253.2793452-1-sashal@kernel.org> References: <20201223022253.2793452-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit 167faadfcf9339088910e9e85a1b711fcbbef8e9 ] When device_create() fails, dvbdev and dvbdevfops should be freed just like when dvb_register_media_device() fails. Signed-off-by: Dinghao Liu Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-core/dvbdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c index ba3c68fb9676b..b19db83e1aeb9 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -516,6 +516,9 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, if (IS_ERR(clsdev)) { pr_err("%s: failed to create device dvb%d.%s%d (%ld)\n", __func__, adap->num, dnames[type], id, PTR_ERR(clsdev)); + dvb_media_device_free(dvbdev); + kfree(dvbdevfops); + kfree(dvbdev); return PTR_ERR(clsdev); } dprintk("DVB: register adapter%d/%s%d @ minor: %i (0x%02x)\n", -- 2.27.0