Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3347400pxv; Sun, 4 Jul 2021 16:13:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwILPGL3IqJ7tckhavH3wR3k22jC+lAK61NUUP5RKOF+fTrEQyTdrs4AyF3USBmOmN2zw5p X-Received: by 2002:a17:906:c113:: with SMTP id do19mr10562509ejc.541.1625440388172; Sun, 04 Jul 2021 16:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440388; cv=none; d=google.com; s=arc-20160816; b=LisiWGP8BVy9g4zB+UVcr6M6grHvOgTvEPSLBm55FxcMVaoTsnr6NSZqAZAekCJL8p +8MnZWTgWlNbdHyAeP+0vWFy0NNlBSL5FH3+VZKqJbwbh8rZjdNO1vRAJvkFJgzYdAWi V8YQo57bIYZrH0/7/bk1zvdrLue4Q1m25h2mxA/jFvT18IMI56oDzfZG8DZ1ZbhkAEw9 BVTUxE67TQhJLr2xT/rrLaL1pNMJ205mzOF7cOSTHB3dfsRDIJGh3Aj9jDYLGL3IrDup NmTjUBZXI475KSl3kV+n9VTtjqbJYfd8vaPWlIe1bm30cPUGe98ZaVr3F/Q1GTMs9isw zS2g== 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=iiWfc6KTdaxumyarKdIdPX34Kt54GKE/HEKtEtnpkzk=; b=i+xpmI/N7/BRhU4ku398UbDUO5TOkvVI7dfthzqZCn8JWibTsoc5Z7dM8VixH2gHOO wnPBl7+8RjKDF1JJB3sL2majtLrKrMPfDO7jvKVlPkQnIFyqZuHbg+Gv5UK8grEyw7dG JfpfpvoKJ6+GHnq4gaQHpTxWwKHwuzgXPe2Pssl0vPuzCB/gHmJrnnubLY9cfsvGBSnK njRq9xHEyA1KjW1xgOcUBEai9rLhQoSGoGD8yCN7awF+dpfZWYqSL+mYrivCkFtLf7pm RKMHW7zOVK8QGM1aKeTC/PnJusNYEk1kccoxb11AqWxLkzArJym+5vvIhg4tQBTLvTJp D0sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cy+P09zk; 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 10si9178583eji.282.2021.07.04.16.12.45; Sun, 04 Jul 2021 16:13:08 -0700 (PDT) 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=Cy+P09zk; 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 S231781AbhGDXLj (ORCPT + 99 others); Sun, 4 Jul 2021 19:11:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:49050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230106AbhGDXKJ (ORCPT ); Sun, 4 Jul 2021 19:10:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADE3B613D2; Sun, 4 Jul 2021 23:07:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625440053; bh=Oc/muHyp/WkHhV5wU9XuA3AaY1FnzFrQ4sTl6k/RmDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cy+P09zkzox1OU2k0obJ7e7X5Jrpp3+OKHbF6dmjA12lO8XxW4IePQuv2E4ho+ux+ kt/eoAO60Fe3qxjYXP0rayRT2csyoPfKaSo2p9ADhQHxKwV2IAKd3UnSFVpK8P15y7 ZFM009IreXtFRO30Ad6BBqlcJ+zzB4BiUGM2L9Lxk7AbPxCwDMnJw+P9t2bx5KxlZu rFK0fZLfpLEjDdha5nchPgbHVI3a5cblhXrS0Dd9xOoj5cqlqlQeNRWEwlotifBAiq tDpskfAKWQLjd4xgfS9gnrOYshMetCQIrrWYw6VT/cSSQRBa3DbfTq6mgDY9jDWWtG 3f1rccUXmOCQg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.12 57/80] media: dvbdev: fix error logic at dvb_register_device() Date: Sun, 4 Jul 2021 19:05:53 -0400 Message-Id: <20210704230616.1489200-57-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-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: Mauro Carvalho Chehab [ Upstream commit 1fec2ecc252301110e4149e6183fa70460d29674 ] As reported by smatch: drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:510 dvb_register_device() warn: '&dvbdev->list_head' not removed from list drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:530 dvb_register_device() warn: '&dvbdev->list_head' not removed from list drivers/media/dvb-core/dvbdev.c: drivers/media/dvb-core/dvbdev.c:545 dvb_register_device() warn: '&dvbdev->list_head' not removed from list The error logic inside dvb_register_device() doesn't remove devices from the dvb_adapter_list in case of errors. 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 3862ddc86ec4..795d9bfaba5c 100644 --- a/drivers/media/dvb-core/dvbdev.c +++ b/drivers/media/dvb-core/dvbdev.c @@ -506,6 +506,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, break; if (minor == MAX_DVB_MINORS) { + list_del (&dvbdev->list_head); kfree(dvbdevfops); kfree(dvbdev); up_write(&minor_rwsem); @@ -526,6 +527,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, __func__); dvb_media_device_free(dvbdev); + list_del (&dvbdev->list_head); kfree(dvbdevfops); kfree(dvbdev); mutex_unlock(&dvbdev_register_lock); @@ -541,6 +543,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, 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); + list_del (&dvbdev->list_head); kfree(dvbdevfops); kfree(dvbdev); return PTR_ERR(clsdev); -- 2.30.2