From patchwork Tue Jan 2 09:48:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 123108 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8770271qgn; Tue, 2 Jan 2018 01:52:17 -0800 (PST) X-Google-Smtp-Source: ACJfBotKU2wgnUTTrGsXzmyMqetciJSmOOiJ4y51hSRn9xsLNlDYlISJEX57UDhsm5pgyqs53YBo X-Received: by 10.99.116.1 with SMTP id p1mr25940860pgc.391.1514886737264; Tue, 02 Jan 2018 01:52:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514886737; cv=none; d=google.com; s=arc-20160816; b=1HPICE/W93CjlNbFB+GTjMlGQj+rLfZSyli8OwNoCSlrY2L/NWKBXugpfNMphYHFJT J2wY35Q75tmROGjx8+Howrvq6kEyEfaITE/5S4faZTv//1PmBcjGqeQvUSUafrvgYFJe QFPgkwxdGGPXhxARVqdJR/06DUUn8AFhA1ZscavHKl03GzrUzXcbhlh/A4pDTSv7nIfg Biu1mn6ccf+NlJ+lDe0NEl8YDixulsVuztFEndRo7Z0Res/kXMGnBZcxqXHNxV8zAvc4 6MTRZ964Dlw6TevZSwLBqwiL9l2cQqtxkXJYl9n6I2mxyr5oKLkBoaG+TFb88zO/UsAF AslQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=bOu0Kb8z61scHXaFmW3LiePFpi4y6JdHcpne/bST/Dc=; b=q2TbFzVyiev5NthmzaE16feQixRRwfqlanKOaoPqvXKEvzJIFGofezWoRPoAnbcUGz +WEg0PjggV51DVe4oxPs0gPJOmRGdUBB2LBmS1p3OsnikGSQZLuxM5jtX/mOkV+YAMmY 1bU0i47nMvt16SDTKidwWKONeTp/+UbZVE9jFuNDkzkELQZZYgyEYXNH3ShLutHeV8H7 TqtMO/Z8vfKgMl45k7BMDAUaTCseSp6BLnVC09aUnsUZAQgjEaDf810t1reyEJO7qCaM ycZGwBXgvEaGIhrs6ld4X+GABEag3pgP5o2QG0gF9Km0bJN/dqSTu5RzO3Wt7kSz4Hr1 UhVw== 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 b13si9408216pgv.480.2018.01.02.01.52.16; Tue, 02 Jan 2018 01:52:17 -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 S1752403AbeABJwN (ORCPT + 28 others); Tue, 2 Jan 2018 04:52:13 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:59078 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbeABJwL (ORCPT ); Tue, 2 Jan 2018 04:52:11 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0LcOxi-1fF1RI0WsI-00job7; Tue, 02 Jan 2018 10:51:58 +0100 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Max Kellermann , Wolfgang Rohdewald , Shuah Khan , Jaedon Shin , Colin Ian King , Satendra Singh Thakur , Hans Verkuil , Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: don't drop front-end reference count for ->detach Date: Tue, 2 Jan 2018 10:48:54 +0100 Message-Id: <20180102095154.3424890-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:VcokeWkH/uWYYjchwB8s0fDEkZ1P0C5rj4hpGX8rW+2j64IoVfD RHhzb0LQu+XRCronxzWqKe+GMXWLi6o77PqaMJ/7xoRZVL+fTVkP2kdPXlFx957gzWoNugT jR4l9Iyzq2HQvBY/piakPTDsdLq2DKOHOWQGDmveINxq6duSWlemv16iJpf4xFX6WMTRZXA F5uM2Yalmb+4eAXxOBULg== X-UI-Out-Filterresults: notjunk:1; V01:K0:C0tKMKHmOYg=:EWQmac/4U6s/t1woqGmRXX ClXLXSJGbOz6XU0BWg361nvM2jNZOG+0RoVwluOjcF6usHFIkCEWsVKidjxQcHi7OzohAPc3n 8BCfoeX1acV0fhz3fGIyvIgDkQBlO0URZgWJheAvAcglK9IlL9a6b9ESVEC64xVHJ8t1mQ1Yl ahLpugAhYVNf90BJo8t0XpuXCGDIFtlsdzSLUODOXLwt3f4qj7wHGIeOG+3gIxuWY8KJkmLRk 5d7x6Uki06FpVtfdUky1aAt0PhfyA2e9ZRVhuLLO+posNcRLfFEtKYApt0I0iW/jyls18+l8h +KCVwH7aLm11L4+XgnECwXbjqDXwV43k56p21OfduVa656J+jy3b6FaLZQ9q/4Wy4WB0Ker0d Gq0PowKRMKJPq9P9nt9TLrAu4cF2U8wM/9E2q2Up2IH1dP8TUJEiLwB5tXISgDzm72PseyVk4 nZznzya8O6dJnom6CpFpPicqMAGrAqSbMt8M6OWydyfBrXsuYfDobw3RfB3h2XDfMQBfze2iB RMssXPbkb1u7k3sfDGaulZvEgj+VHiPk7NEJ52Cgi1dDhNKP6VcejBJCz9ODhcOiieac2qWPo YAtJrL2aP/xdjmoEZW3cLOhy0fHSDHISD6kXMyq2tfVe2zXhZj3PNZhq1Y4nuCgrTuVmZrBsG yXF3GADi4JvsT7kbQV4I6LB1hg3HiO0X7R2VotEZgfNclzgqm9aFIzsB3+YzCPeG6DfUYyj4W y6FUfivhqhLAkNFL3d4Ek7jWWafH1ut8JclZ1A== 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. Cc: Max Kellermann Cc: Wolfgang Rohdewald 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 --- drivers/media/dvb-core/dvb_frontend.c | 4 +++- drivers/media/usb/dvb-usb/pctv452e.c | 8 -------- 2 files changed, 3 insertions(+), 9 deletions(-) -- 2.9.0 diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index 87fc1bcae5ae..fe10b6f4d3e0 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. @@ -2965,7 +2968,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 0af74383083d..ae793dac4964 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");