From patchwork Thu Oct 3 15:53:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175142 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp565975ill; Thu, 3 Oct 2019 09:36:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1gLujfuGLO72+iIavT3ZMZpEdylEOdLKJ1d8v+JVrBSNiDk5M2mqBBuBfpbZwSBxQ2Rux X-Received: by 2002:a50:9625:: with SMTP id y34mr10343445eda.72.1570120612068; Thu, 03 Oct 2019 09:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570120612; cv=none; d=google.com; s=arc-20160816; b=YLyaYM079FjyMhHwOvCa7nhfNsW2lzRS35rvoSlZMfPsm7sQL2UfI1hvjfPchJbKj7 0HdhuQZmf0a4MT7Uc4SbXeqjROxP99vlGwhl50DNDn4qwKNmd+e+bCqRFNlUz26xpCEF IkxrdCn2bIGW4J42ZO6xIoURkfoC0tKRDPhWbYfuN/it/YNYEfbw93XlkneQZL6Uhn/0 IQXqkBLwKgYVeAD8DBTaUAlAi0AjCQ7Z6wvDvkAjDIodQ76zkoQqLXTbehkOXKGraIhk fNFvcVzBKOKtwHhdYz/uh5YOZI7d5VEVP7wtqmkWTMf8yX3I2gg0Vq+zG29VtfN7GNpP JUHQ== 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:dkim-signature; bh=N9azd5mur+/EDKPw6lFppY3BpD3PWJ7DNldedf2r5o0=; b=FbOf9591bl1vmvsqF82PsPFLJWEkbZzB4gsQVN4hyk4F2YzRJOeTfTM2SDCon46sPX b9wGiqURJNDVzYtvf62j5hiYL6FRZu3st4wBCSatzLsVRk67x2CJRHQyClWOlcG5Rf6W RKODyPq72Vdbqi7GxmC+RZNlXg+Pj3aR1L2uFI81EHnj+ZGlU5L0op7uAqPdOnaAh3Xp +7uslMWttuLFCgs7xB7pnIGA7wqbMmpZGLiK+tcvhaNkzjQxVk3devZIIivZwmat1ndq xTj7WPMCgAuA4vAuIXwXhyVqbmFsLlwYc+3dF6h2SnEmal3WSNWfHi/KQ8tpVFRt8+Tm V/MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xDzgNUkR; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 f21si1635316edb.379.2019.10.03.09.36.51; Thu, 03 Oct 2019 09:36:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xDzgNUkR; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404476AbfJCQgt (ORCPT + 14 others); Thu, 3 Oct 2019 12:36:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:46074 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404472AbfJCQgs (ORCPT ); Thu, 3 Oct 2019 12:36:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C6A32070B; Thu, 3 Oct 2019 16:36:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120608; bh=eWEvCVg3wCcSWm4Eo/WgV+HNSy43PDfiVqy2M5m3Wfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xDzgNUkR0meLqxrTyvpIVkoOwAYuo7KQtkhb3ACr9FP/Rdp/mgIFeu8jtP9UP5VWc piGBGP1l9SlnXYnZWjZ50OrCMZf6hXa3Sl679F6WL+qqNAHL0JMjGOJSydMlUW5Zem Elten4HmY6lXzvaHl6qHU+BRnWl2FO9L/h80c/B8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Max Kellermann , Wolfgang Rohdewald , Arnd Bergmann , Sean Young , Mauro Carvalho Chehab Subject: [PATCH 5.2 247/313] media: dont drop front-end reference count for ->detach Date: Thu, 3 Oct 2019 17:53:45 +0200 Message-Id: <20191003154557.370657877@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit 14e3cdbb00a885eedc95c0cf8eda8fe28d26d6b4 upstream. A bugfix introduce a link failure in configurations without CONFIG_MODULES: In file included from drivers/media/usb/dvb-usb/pctv452e.c:20:0: drivers/media/usb/dvb-usb/pctv452e.c: In function 'pctv452e_frontend_attach': drivers/media/dvb-frontends/stb0899_drv.h:151:36: error: weak declaration of 'stb0899_attach' being applied to a already existing, static definition The problem is that the !IS_REACHABLE() declaration of stb0899_attach() is a 'static inline' definition that clashes with the weak definition. I further observed that the bugfix was only done for one of the five users of stb0899_attach(), the other four still have the problem. This reverts the bugfix and instead addresses the problem by not dropping the reference count when calling '->detach()', instead we call this function directly in dvb_frontend_put() before dropping the kref on the front-end. I first submitted this in early 2018, and after some discussion it was apparently discarded. While there is a long-term plan in place, that plan is obviously not nearing completion yet, and the current kernel is still broken unless this patch is applied. Link: https://patchwork.kernel.org/patch/10140175/ Link: https://patchwork.linuxtv.org/patch/54831/ Cc: Max Kellermann Cc: Wolfgang Rohdewald Cc: stable@vger.kernel.org Fixes: f686c14364ad ("[media] stb0899: move code to "detach" callback") Fixes: 6cdeaed3b142 ("media: dvb_usb_pctv452e: module refcount changes were unbalanced") Signed-off-by: Arnd Bergmann Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/dvb-core/dvb_frontend.c | 4 +++- drivers/media/usb/dvb-usb/pctv452e.c | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -152,6 +152,9 @@ static void dvb_frontend_free(struct kre static void dvb_frontend_put(struct dvb_frontend *fe) { + /* call detach before dropping the reference count */ + if (fe->ops.detach) + fe->ops.detach(fe); /* * Check if the frontend was registered, as otherwise * kref was not initialized yet. @@ -3026,7 +3029,6 @@ void dvb_frontend_detach(struct dvb_fron dvb_frontend_invoke_release(fe, fe->ops.release_sec); dvb_frontend_invoke_release(fe, fe->ops.tuner_ops.release); dvb_frontend_invoke_release(fe, fe->ops.analog_ops.release); - dvb_frontend_invoke_release(fe, fe->ops.detach); dvb_frontend_put(fe); } EXPORT_SYMBOL(dvb_frontend_detach); --- a/drivers/media/usb/dvb-usb/pctv452e.c +++ b/drivers/media/usb/dvb-usb/pctv452e.c @@ -909,14 +909,6 @@ static int pctv452e_frontend_attach(stru &a->dev->i2c_adap); if (!a->fe_adap[0].fe) return -ENODEV; - - /* - * dvb_frontend will call dvb_detach for both stb0899_detach - * and stb0899_release but we only do dvb_attach(stb0899_attach). - * Increment the module refcount instead. - */ - symbol_get(stb0899_attach); - if ((dvb_attach(lnbp22_attach, a->fe_adap[0].fe, &a->dev->i2c_adap)) == NULL) err("Cannot attach lnbp22\n");