From patchwork Mon Mar 4 20:45:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 159621 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4193259jad; Mon, 4 Mar 2019 12:45:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwtb2TJK+rq0Nr0QsfwOE2doMB80cZLxGMCeaekSRa0+I6QfeXHfylBlFLxoL1s69rmikwD X-Received: by 2002:a17:902:48:: with SMTP id 66mr22792647pla.9.1551732342337; Mon, 04 Mar 2019 12:45:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551732342; cv=none; d=google.com; s=arc-20160816; b=v5ED+JoVVCF90UfXymtKpz4r739E+5U3bvSpZGeqwbSWZhzqy64zyFsjIdSOA++1vn EIUBYJNO0Qq2fq31AzJ+H/k+l/Il9lVVMEnvpbA4dxGrieszAAuSAWek+1Lb4ZUNY/ex wBhw2wIlx7psV4IjzZEBNIh7CemOJh7YXt8y8Id60jB8dy4IaLDhKBBu9QHPuySJ4nqW JAqtchVhSTnL2Mq+GGptEJa0JGcdBg2Y9NpYQnH8QgxND/Hkg8CyO0Hg6rofSx1m3qZH KifsNuyXYDy8ShIMtYRcSnSgFwyvRXvjXCG86xa7E/oaij6wjdkK3Z0ExKWbpwyKGwc0 O4tQ== 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 :message-id:date:subject:cc:to:from; bh=xHR5REiJakzMga/BR5vynfZ9p9ImakWPTBoyQltDyjM=; b=MPQXk9UWX3EnZOMnKU55vNjVMygoNZHhvHNQVXOk8jpP9TKVIxG/GajaN5wfKoBP+E IYYD2b/CW5XLL989NHIofwyhPmtbrM1Kg7avp7m6ObCic7wkBosendcksS38Hs7hD/1W /TqqW9VYCErJogyQXudSHc8JwR6wp8GeC9ZNBZqyGMteoNyTMiYciTyNV7Os7op+s9np RxEot1pNkeEUQp7D1ESr5Hkp6yjAdFCiPQ5+wW6deM6OzFg1VTi6xkIn+iWPs58717UF IP7lfQCJpbgTYwA1oR8/Yd8hVON1SP/ll3GbhCQ70HQqQvFuaUCTvgOMk5U0AWnmDUTV NIAA== ARC-Authentication-Results: i=1; mx.google.com; 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 u18si6126926pgn.590.2019.03.04.12.45.42; Mon, 04 Mar 2019 12:45:42 -0800 (PST) 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; 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 S1726672AbfCDUpk (ORCPT + 31 others); Mon, 4 Mar 2019 15:45:40 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:39135 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbfCDUpk (ORCPT ); Mon, 4 Mar 2019 15:45:40 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MTznQ-1gbA6M1Szq-00QywR; Mon, 04 Mar 2019 21:45:28 +0100 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Max Kellermann , Wolfgang Rohdewald , stable@vger.kernel.org, Akihiro Tsukada , Hans Verkuil , Katsuhiro Suzuki , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [RESEND] media: don't drop front-end reference count for ->detach Date: Mon, 4 Mar 2019 21:45:07 +0100 Message-Id: <20190304204525.2283399-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:iI74MnyTBaXWF8tbrf+pNC1Oojm3y2POdwWl4TEPZLyoh5CmnTP Nruwx81FdKEr7tPiQUdTLiorqdtpDshY82RJko3tC6QX1RrPkxgON9SSySfZx0g+bGk6v2W EaZzbVxlolwwhoQgU1dShBaNO+vdFEKUGUMaseLEVs24TtCcicAw+AjU3nAgNfkub4N6CI2 YrFcGI4Na/RqzEZBHjGfA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:ZtKn1Z0UpbU=:He3v2Sb2TeeN/7q4AkRnn1 HHBPkv00h9vt/m7fbMgZH5yoirS6b1+CLRioRn89JApFOIl+yzUSrKLTdHU8oRBjAQU7YXCGe w/nQdVZjd3nywv+hbfdWVMbBGhGYkmi8L9MSbDiB/0PwTW4XV3n1pIoj7fcdmaWdkmpxh5ehy AwERIwynB1nVSvp+sbSu9KCEpj2keVN37PtjmaEmkgQVZYu47Nf1Lr2nD4rnjPIms4jpo66XK pXF0x8tMb4qw692PH90jXLrFwYwoZTaFNH0290WafyQ2fuBk2IaHCZM8jIYKTCilDKEwfjhD7 MGnfkbbV9MRTUCwhA/SjBOIVbEYcJDGxnUEkrWu1kmwZK4mNCvi7HzQWXA2gksvMxIwMSF4Em ijERTOgZuexGltM+nIIprSJJ7Lwh+0P0k4rkTsGokb2NXdrs00K1es9QlhyzMShg0DxEJztwo WMm+yA/Aa1CSUHhuRozpZIuaRBbSRKufYsHhCaEFg05Aleq1IhOqKMQb8pnBmhwLhtRISu9Mb c1E1eYS+geT9p7NhJyzrB0PY+tPxOw9TKKaNB0tuLOaUvFtGP02tolTDdacnhRbi3SD1hYlUt KqRlYgJyro4jho4P26b6EhGge299eIw5eldXCFRx5QKpDbVGg3aFxMyKkVlV+ko2AiomiuJTk YyEgte0B8K1Kw7gzqyjZ6MQwvK2aA/3ofrPSiDgK8jLG8wiYpihd/ICEhkQ54QSTPUNBVHgUb 5gZWT0xPRNvFYPOLnUYstXxs2EsfDUrvnFolfw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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") Link: https://patchwork.kernel.org/patch/10140175/ Signed-off-by: Arnd Bergmann --- drivers/media/dvb-core/dvb_frontend.c | 4 +++- drivers/media/usb/dvb-usb/pctv452e.c | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) -- 2.20.0 diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index fbdb4ecc7c50..eb5da50ff95e 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c @@ -164,6 +164,9 @@ static void dvb_frontend_free(struct kref *ref) 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. @@ -3038,7 +3041,6 @@ void dvb_frontend_detach(struct dvb_frontend *fe) 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); diff --git a/drivers/media/usb/dvb-usb/pctv452e.c b/drivers/media/usb/dvb-usb/pctv452e.c index 150081128196..5c653b660272 100644 --- a/drivers/media/usb/dvb-usb/pctv452e.c +++ b/drivers/media/usb/dvb-usb/pctv452e.c @@ -913,14 +913,6 @@ static int pctv452e_frontend_attach(struct dvb_usb_adapter *a) &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");