From patchwork Thu Oct 3 15:53:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 175167 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp589313ill; Thu, 3 Oct 2019 09:57:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRWrO8atSDXv+0x6XsfwBclGuLjs42WSoJuJruGAqwPjZpw70JH+Z66EEl2/cP/5184bMI X-Received: by 2002:a17:907:20eb:: with SMTP id rh11mr8416820ejb.25.1570121834833; Thu, 03 Oct 2019 09:57:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570121834; cv=none; d=google.com; s=arc-20160816; b=qwe4PdZoiZJHTagJP2G6/r/8A0SeE+j+r3HHFry3tU0u9lu+Yh60MZZXhENGx6NZnK FarMg+UydmCjy58zrXGzv+y+cxgG8X7Gt601OHLrJouqijI0da4LRQFEGXrn31edObPA kUE5+3BiKPG4QpSx4KFu9Zq/PqQTdJMzFSfEc6iOrdAUyRfl1YYQI21kCDW32C5KKnDJ WU/o1kxRPdBoLjbxd+9dhspMIPGC4gtIQsFk0mjKaybliWpWSGLsBCp7qrGNeYv6cET1 +QDHNnLMiyjOuyz5C6lxf8oHUz3kHEOCET1kaIywoRRaGyfDUmgAdUVfoDRr7w534715 b2gw== 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=SUljDWYNpkbWUfdAsGBgy1pPlCItBaFY1ayUMkStQrY=; b=NEbSRbMUIEMAK8lqiyaeR1Pvvyhonoa9TqD05PJY30VWYEg+4r3e0qpK4Gqnfi8BEW f+T3Bg2V8ukfe09RRPlMzFFg+I7vsHUaBCkusvz1lD9hrz5VRwu5OQhWfEpc1lRN3mBm TdcrJUNsCokjr5yXTJeqZpxYuGd5OiHvXAXtltnOOMjlVPX7TuARNXozTk8XrdtoiboY CqZJoU1n+oDHO5Yuu9eO6dGwaIDM7FJdRrazv2zSzSi+DpnXyyHLWOn0C9g5OaIP8FCU zzOvveCCd+zGaXt9kdFa/uKS4hXBCT0Ri/aZ4PCI3IngiUvzGTev4IFQG4MYV1jvDtSY dw3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aLQjdk8p; 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 d52si1836181ede.370.2019.10.03.09.57.14; Thu, 03 Oct 2019 09:57:14 -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; dkim=pass header.i=@kernel.org header.s=default header.b=aLQjdk8p; 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 S1732288AbfJCQ5M (ORCPT + 27 others); Thu, 3 Oct 2019 12:57:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405013AbfJCQuQ (ORCPT ); Thu, 3 Oct 2019 12:50:16 -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 3C6D42070B; Thu, 3 Oct 2019 16:50:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570121415; bh=rv/sl+mL7lEXLkuRhSTikzTsj23M93TzHboTgmeC/qA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aLQjdk8pZ4d7NGlmXUpgs/O86qZU2Ky1NB53C+tXQQQGfyXBJWSRXhuxyiSx8W7Wh ao9YD6hCJr4f9qTWVJ+dUg5MdYIEw0FryzDIEt2J60A2k0EMLratJZ+2HewVhClnd2 +0YGtIYymLPKWZv7A3UJtI4scSZy/z5k74ZMW3lQ= 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.3 271/344] media: dont drop front-end reference count for ->detach Date: Thu, 3 Oct 2019 17:53:56 +0200 Message-Id: <20191003154606.976684706@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154540.062170222@linuxfoundation.org> References: <20191003154540.062170222@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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. @@ -3040,7 +3043,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");