Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3344621pxv; Sun, 4 Jul 2021 16:07:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8iKfKfPSPwvTUtnhgE6zFhKBv5FR142E3OiCfpAXyxvD9DZBGUiGy/Osp6vXMLnLhJOSg X-Received: by 2002:a05:6638:1505:: with SMTP id b5mr287675jat.105.1625440059669; Sun, 04 Jul 2021 16:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440059; cv=none; d=google.com; s=arc-20160816; b=gIyxBTEChdXpKkHxBJeDJrMq6IUepi1iLWp1XwbOnjif2bpnA7hVzt2mnMo3DVDfqq 3wqnCO40lT+sJCvX5h4ENDfUmSjdsKBZCO6gtNXYtVjo9+hRdGvi3tHj/EPz2rA2FSBJ 8Ly/9dXkSuCDjqDecvmErPjKgii/rNiH+v+9jr1WRmrb+QAUWboqrIcNnYGgOu4JWRhO Kv7QzwPE+DIJ/THq33a/v3AiMbKMF0BwHBEvytdBHPMq0iyIVJGf0ZW7xAeJtrRuKh2l 44PvnaTtH90U9rYIzFivesbezoS6qGzEoeOrzeOofpAKT1gxEK6v7wbOFwNBqTOvyn1N rSiQ== 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=mmIDVDuTj/vBo/uBPjq99iftgeXK00UXJVwob3+SVUEylxL3Z1+2zre9IK517p7t/I kMqSXEEgCfunLSgFJIk0FQUxfLhpwTQXFYoU8YbNtYN5/htJZn14QlvcMBzprl6756Pi k7T8Nx+SI5AlGQsc18iX7vOs1qrruB+hPMpeq5GxAEAiLSECMsLy4USK9JSGHJ9s0vpe XIN+rKaBLvxejH/ZOofNpl0VLWd7t9ySDNePrOL0KJk6huv9ExZ/rAHm6UvpFbQwVb22 CsA+kkKNLoeqEQaJpE9xgnA/nB6xXkRo43JiW7v7zKOI8ezZi/ntiPQ9K9kidsYQ/BAg oV9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SzQIAO48; 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 r4si11265803ioh.93.2021.07.04.16.07.28; Sun, 04 Jul 2021 16:07:39 -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=SzQIAO48; 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 S231761AbhGDXJF (ORCPT + 99 others); Sun, 4 Jul 2021 19:09:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:46804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbhGDXIT (ORCPT ); Sun, 4 Jul 2021 19:08:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5D8E4613D2; Sun, 4 Jul 2021 23:05:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439943; bh=Oc/muHyp/WkHhV5wU9XuA3AaY1FnzFrQ4sTl6k/RmDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SzQIAO48K4wj6gbCCHMy2Fh8nGlawBum5G47z1qmtg+plxzlh5P9KeKMMvlSYjjQl 7Ws26nPXzr6d1BPTh44Fmaw89uCHhgJGXajantnaREAZZbiyAQjYLQHnmIYwlE3t+A kOVTMsBW2Re/d12n52tAZhISoniLK8h8YUFCis83MxRUH6CUjivFj1dwwBkrbAJI4A rr9zwFcBlYKgyJsyELdLR/+7iScKNu2I80b8bFWCFiYJBnvqNQ9HgKHmXi7QJPobUb yyiwBsXll7+xwsBxnzStkoX9NWPIgMPKKAM3io4I04BDHcmJ1kOofx4xIMzqqi97z1 kD3nA8kegcK1g== 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.13 60/85] media: dvbdev: fix error logic at dvb_register_device() Date: Sun, 4 Jul 2021 19:03:55 -0400 Message-Id: <20210704230420.1488358-60-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-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