Received: by 10.213.65.68 with SMTP id h4csp1448124imn; Wed, 14 Mar 2018 22:58:05 -0700 (PDT) X-Google-Smtp-Source: AG47ELunVbJMvsKPg7FJ0REZUgEql0Ymd1o2vTU2CaaHFhkhb8kneiFcnluUfgLwkMHjIZm4+l3G X-Received: by 10.99.154.18 with SMTP id o18mr5953354pge.344.1521093485751; Wed, 14 Mar 2018 22:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521093485; cv=none; d=google.com; s=arc-20160816; b=GnZs/KShX0yvxfGZRt0ePzc48UxE/Vt07IaaVZj/8ja2+z4rJxSyx7/LZhSFV/YqmN +sWv6kheQnTDeAkXnv5b+XNL3EpSW89hTTPLvUIPa6LwHb0jiFoBf0LDHgzXllYiO6jH jtxsBGQJVNXXoZBTmIrKkK2cKBlgVjHkEhKbBzUnwuyBaawUef/b6SxHLUo+stB0hmBP GU2CICyIarRBU/RJurGM8thlsUZZ4adNQArVus7m0LkBXvPMxyqURl828vUAZ4CXE184 mQiPrNyV0UXPji2juplyaZZWMRwB8yKuo08cl4SFwP8vf8ZMeHBFVnhZhKkKsDV9LzHO YmDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=IkOJo/0lWdrYb6QHuUkF5WDVy6jd1PFJX2CJg0qDu4w=; b=T8yzHhHDKPjy68+UslkokZnnYnqkKTyvcmA76Un8dQVTGzlmkmbZE3fpseAGq7YBEo wvrT3qE4/lLN35Ic0NY4kF+9vsB7ugKWhMH0KNbC+D7WYE5RV+1Q+Kp74DDsZFrxcLit IsFVBGAto4bhFUmUcceR8VYsX23FYAw9wc9DsIEaWA9uQr122A32y5GkYVKJNvUrqv03 IYGNMnXTf0FzuZohE3FpWhgfycwh5BVIFiNsfnZhvnqcO1U40R5FZPV/J5ceiLooGYDA KFrs1VYPhYUpewgWdP3xvPIeBZNuEY8ZpEOULPXCWpBa5o8ujbvIrJAeFJ+IA0GXJYWW LceA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nAjt1ylp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66-v6si3336760plb.314.2018.03.14.22.57.50; Wed, 14 Mar 2018 22:58:05 -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=@gmail.com header.s=20161025 header.b=nAjt1ylp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751551AbeCOF47 (ORCPT + 99 others); Thu, 15 Mar 2018 01:56:59 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35728 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750722AbeCOF45 (ORCPT ); Thu, 15 Mar 2018 01:56:57 -0400 Received: by mail-wm0-f67.google.com with SMTP id x7so8096846wmc.0 for ; Wed, 14 Mar 2018 22:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=IkOJo/0lWdrYb6QHuUkF5WDVy6jd1PFJX2CJg0qDu4w=; b=nAjt1ylp+Bb4O2AjkbCjS7IdE48okATPAV1Dc/xmBlEMPrTt0zGo+R9LWRMJbS+YHC +V6siOA9AEouoG+8QR2k/uKeYx0ITc/J0pwyODrrhbfM+SgwEhidQWZ2zcu+1tjLXrPx 872DTSUx+g7832c6M5ruGZxqwqQlVZgVrvtBsBQFZKCNOkgonOZEV30Brsr8IXQ3QbEy xAmcGj6h6TLiD7CV7B7SmcxD5wp/XZwtouOcgHqLOZ5hroH13ANuFjCnGL/l305VYhlt co1voYMS8S6jL/xOCFjvbt/R2G2pUCVdYTC3uFx+0LWAsrUIpPqP5+CXlu8Rut28r673 hL3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=IkOJo/0lWdrYb6QHuUkF5WDVy6jd1PFJX2CJg0qDu4w=; b=nhritmL3O8vJJpIXfD1NbpnTApW294S+t/LXTikrXydXUOcAzXIo7BxqwFqXOWFF23 sabN7uoBG/KYjy/LELRdkirL031GS/CDIznEhlTZMGRBZR85GQqP2BhdJdTSyRT+sY+q oU0KrQOuGdtjiOeus4lK/APgn4AfBfgpFVWZtZco3mP6M6jDUyQV46MPIUnATexPaFsa d4033do1d5xEx8jEbMJWy0ZuHl3hToyUf2QsKg42GEAIQdINU9pM95/oIyp5/yRUXADu Fh/tHMc70zqlhiN9D+G/jSpKb+Q/oepeMJ0R9c0KJVDIlhWaXBgEkLFg0iouFzYhHSV5 JvTw== X-Gm-Message-State: AElRT7FdqGuhftb2bR81OHFsNaO/pWmSPqdrnFobNdMscN9qo3RoPmyK RJZqeRoYIw1Y36SS8e58y4laHhypbOnBsw== X-Received: by 10.80.173.238 with SMTP id b43mr7245928edd.203.1521093416433; Wed, 14 Mar 2018 22:56:56 -0700 (PDT) Received: from [192.168.1.3] (x4e337d17.dyn.telefonica.de. [78.51.125.23]) by smtp.gmail.com with ESMTPSA id z11sm1138977edh.94.2018.03.14.22.56.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 22:56:55 -0700 (PDT) Subject: Re: [PATCH v2] staging: bcm2835-audio: Release resources on module_exit() To: Andy Shevchenko Cc: Greg Kroah-Hartman , Eric Anholt , Stefan Wahren , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list , Michael Zoran , linux-rpi-kernel@lists.infradead.org, linux-arm Mailing List , devel@driverdev.osuosl.org, Linux Kernel Mailing List References: <63ee611d-9fd7-a67a-45aa-229cc4a83ed2@gmail.com> <20180313193414.11535-1-k.marinushkin@gmail.com> From: Kirill Marinushkin Message-ID: <1a59a938-0381-49f4-dfd9-c7a52bdb0eae@gmail.com> Date: Thu, 15 Mar 2018 06:57:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/13/18 22:23, Andy Shevchenko wrote: > On Tue, Mar 13, 2018 at 9:34 PM, Kirill Marinushkin > wrote: >> In the current implementation, `rmmod snd_bcm2835` does not release >> resources properly. It causes an oops when trying to list sound devices. >> >> This commit fixes it. > Nice catch! > > See my comments below. > >> static void snd_devm_unregister_child(struct device *dev, void *res) >> { >> struct device *childdev = *(struct device **)res; >> + struct bcm2835_chip *chip = dev_get_drvdata(childdev); >> + struct snd_card *card = chip->card; >> + >> + snd_card_free(card); >> + dev_set_drvdata(childdev, NULL); > AFAIU this is done by device core. Maybe you are right. But I don't know, which function in the device core does it. It is safe to have this line. So, I suggest to keep it. > >> device_unregister(childdev); >> } >> +static void snd_devm_release(struct device *dev) >> +{ >> + struct bcm2835_chip *chip = dev_get_drvdata(dev); >> + >> + kfree(chip); >> +} > >> /* chip-specific constructor >> @@ -122,7 +136,7 @@ static int snd_bcm2835_create(struct snd_card *card, >> >> err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); >> if (err) { >> - snd_bcm2835_free(chip); >> + kfree(chip); > Do you call device_register() inside snd_device_new()? > In this case you might need put_device() here instead of simple kfree(). No, from what I see, device_register() does not happen inside snd_device_new(). >> return err; >> }