Received: by 10.213.65.68 with SMTP id h4csp597717imn; Tue, 13 Mar 2018 14:25:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELuPqpUiwYK8kz5oTaJnCMxyrFpEwRBA/CEvd5tQmxR1+0o/ND/KCzwiNyzOzAfUt2q1rv6+ X-Received: by 2002:a17:902:4083:: with SMTP id c3-v6mr1854020pld.70.1520976314613; Tue, 13 Mar 2018 14:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520976314; cv=none; d=google.com; s=arc-20160816; b=IIz9Dnm8M8/z9mbJhKI+LZplXXytyyMpvHbyj1bCp4qHe7cyMIzbJuHC/8Jdrbbixr SsTBGt+Xipq5qJSI6T0ebob4aHQBMD+tB1a1v2LZEU9YizSbVllq1cZe2XfNWN6a6SEO aknhQ1inoPiWSVpYSzPE9Fd9a8LgFbTf+VixDyuteu9NDmgk68U6hljXB6WBoL91wWdV 4RhCZob9uf0oHU0Ooey5MzPPJUoXg7IJsY3xiSrZWan2eKBX4YOo8YqGhyfmQh41iS7n TKfsUdKirGfAoVzO3ODhggJk8uMEA8wGp/FPK1PrqhXEJzDAynwAg7NQk89vOdcVE+9x d8tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ghCL+h8no4Yx3dgd2hvqYPnQEZdmZ1FmDRmDJZ4vxWI=; b=Uxr9UzIJVl4XeBLkmvToZvMXXiZIEBqmefAgeMnxTaaT4DTvMznqujc8G0YgGTD1pl RcrMma7xRm1JLW3JrUz6fmflVh05KQLYx7l3o/56D0TxdZD56BhV8Umkw7R/BKzRUW5c +9D/ncQmtet3LNH/O7cY9Cmr/X1fqnYVO87IbtQGKVnz1BbEaF7RcvIiVqz8FNS7IUtQ Q+DECbRKXGVE8s+7rXDDkLUlXoHr8kX6F0vBxiq/ENlOH2GJ/wSX8mwh18A36Dr0YrKL ftqPAkZJJFuv+tRqZvX6WYUJVuq/KpRhgkOe7OQd9F3D90P7xKFLrHbht29zuhCgo8w1 HhGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IVtvChsC; 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 u45si671217pgn.702.2018.03.13.14.24.59; Tue, 13 Mar 2018 14:25: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=@gmail.com header.s=20161025 header.b=IVtvChsC; 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 S1752884AbeCMVXl (ORCPT + 99 others); Tue, 13 Mar 2018 17:23:41 -0400 Received: from mail-qk0-f170.google.com ([209.85.220.170]:35604 "EHLO mail-qk0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbeCMVXj (ORCPT ); Tue, 13 Mar 2018 17:23:39 -0400 Received: by mail-qk0-f170.google.com with SMTP id s188so1294733qkb.2 for ; Tue, 13 Mar 2018 14:23:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ghCL+h8no4Yx3dgd2hvqYPnQEZdmZ1FmDRmDJZ4vxWI=; b=IVtvChsC9QXRE4FTGLxhMlSI1jJWvw5JCKeUI7/VQXH82Nf8Tz+ccxtEURdbfpCaLQ 1lAlVFLRf2/fPy9uX7+uYp1xbAvh7O7+k4dF5NOTzfhGTp+/gVP04HK41+yXEQqOOWB1 Zz9vuXxRL0/DqBrBrDOX9xa5sf48bJSZaGiUqMPLDnQLl13ogP/erkVj9DOF/fR8gCkL 1OEvT2MKWgZfMHqMyxEVd4xWQ+bsS8Q+zOQ1gb87kUdTCfBIiovQp72e5OQZBrZw1lcZ OWejO2KEunYR5KuHC+sJOF5qu87epb1E2p5cla9OZQaVdNtukbxhTjPXHbBO9ZBGYgY7 j/Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ghCL+h8no4Yx3dgd2hvqYPnQEZdmZ1FmDRmDJZ4vxWI=; b=GuNRjQs4fW/UOMP2NVNY/VvnwySx7XlfnpQuEip8qThi6Nin/3HCp4+DzENpb12ZZD VEq3ewMRv8qxXAYzrnsg/LiBV6uwDcI3c06luDjpOYfwHo9rqUaYuz9UpmeXTsauNvwi hExxJB4c/dpKAge41G3lVT6xzmUbX1zk18ME/HFL1Ax4F1W7SdBMfCF1BSqrtGsIDyba 82lRDtlI93vmnOz26f8nET0V4JR9VfKBZfd0EP4gg7iBXLutpFQdHvBV3hGcUO5SGBnH uHPxXzNcGpVJx5n5q6UbD7uU1nOpqsi2KvnSoqhhE/LjbnbU0+UjgNkBHBmd3uDFHfth f2bA== X-Gm-Message-State: AElRT7EO0Fq6yjdg86wH4a2Erm+5Z+I9mK2F7z/0zHgbszheZf54HLDu hSHuycYgNWQuyFYMn8OQufdmBWihdFZPuJOX7V4= X-Received: by 10.55.245.14 with SMTP id l14mr3295589qkk.301.1520976219257; Tue, 13 Mar 2018 14:23:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Tue, 13 Mar 2018 14:23:38 -0700 (PDT) In-Reply-To: <20180313193414.11535-1-k.marinushkin@gmail.com> References: <63ee611d-9fd7-a67a-45aa-229cc4a83ed2@gmail.com> <20180313193414.11535-1-k.marinushkin@gmail.com> From: Andy Shevchenko Date: Tue, 13 Mar 2018 23:23:38 +0200 Message-ID: Subject: Re: [PATCH v2] staging: bcm2835-audio: Release resources on module_exit() To: Kirill Marinushkin 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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(). > return err; > } -- With Best Regards, Andy Shevchenko