Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1268815ioo; Sun, 22 May 2022 08:58:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5IF6hU+EcWRo6izNVAkBXTlKJrqxAM5kXAbdemvy85rqzO39OesgGumJ7BujleOgs9uT4 X-Received: by 2002:a05:6402:1542:b0:42a:ccc0:b1dd with SMTP id p2-20020a056402154200b0042accc0b1ddmr20172091edx.341.1653235080622; Sun, 22 May 2022 08:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653235080; cv=none; d=google.com; s=arc-20160816; b=HwdGdVjBtugQDFh0Hend9ttgwR4tdR1gpkSF4oBO0cQA2p+aS7yw8DzRpHCb00mMr3 3lFKqAqXaaUSNl/BoP0Ro1tPylY4JQsG5GzGRVNGEMOvUvyXw93oTKIUZzC1jQ9tW7JS LGTu4XrFSFt08C5VgxLqzh/J9CoqZ3gG3lYLZpqOFqknpsDRucAWgYsb+gXMK6mD1kH7 VibPxXHXqkaI83m6NPywwSstGsw91SrAufen3lEg0tC18HSn8H7KtHj+Lgmv8v1USzFN HZZ3hCkAjGDxqb7uMLHrTqYQRFbVmS3i0JA4rDRhVEtmnWk+xjy80YbiFls9y54VXLYD g5tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+D73FWhjpudKodRpF5EPs72b196mVmZ64L2xG5/iPMM=; b=DQqwllD0acc2a0rQoGiSupNN+Y9gn0cPGtWe6mPa2Xf5PCn3+FlyjiIxWcxSOzO77g kDYeXY3fXaj3oR0DWHsO35yh5HgnG5r7ME7gh6GJgmFYgHNZMTV0u16My8NlLX6Cv0JD Zs2nXP+e6gxboVCIMO2zIDWiXjOWQb6rAYGAyc0sq96akW68wKHmLhdEpWY3aMHUwOCn DGy5+yRx+5LPB5zZTjNxGYWGKMySQWjm7DQYcaymfGOuadDO3r01heDK0Jmc5sMcqU0J gMEk25EL8+1Ep0sEOZXSVw+vtxERKmkHoC7YZOARkeZZaZud0/xXWpVZ6JSN9nTSyvgi GSiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f8cujE0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qw37-20020a1709066a2500b006ef8550b474si13601477ejc.211.2022.05.22.08.57.31; Sun, 22 May 2022 08:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f8cujE0A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240929AbiESP0b (ORCPT + 99 others); Thu, 19 May 2022 11:26:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240982AbiESP0K (ORCPT ); Thu, 19 May 2022 11:26:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD9AC2FE78 for ; Thu, 19 May 2022 08:26:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9186AB82291 for ; Thu, 19 May 2022 15:26:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3A5BC385AA; Thu, 19 May 2022 15:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652973965; bh=dDnUcNYZBVw4u08LEGNx6dxhis/Ia2b/IAkAEH7rhpw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=f8cujE0ATdN96B6fxvhC7nfzmtTdUl37pV+/tyQaYLcxnZ5RXXrL+FuZyhGEDfaqJ rm42PKqFP8DntCCaJzQmEEx32ZNKvFaAXb+0l4d+UscWZacELDMPh2AkkyW8FeOTuC kuji9ZmBC/mWtRugXMHqJZkNKZtLzVhCGGWEUlEo= Date: Thu, 19 May 2022 17:24:29 +0200 From: Greg Kroah-Hartman To: Chris Down Cc: linux-kernel@vger.kernel.org, Petr Mladek , kernel-team@fb.com Subject: Re: [RFC PATCH] printk: console: Allow each console to have its own loglevel Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 19, 2022 at 04:08:04PM +0100, Chris Down wrote: > Greg Kroah-Hartman writes: > > > struct console { > > > char name[16]; > > > void (*write)(struct console *, const char *, unsigned); > > > @@ -179,9 +173,11 @@ struct console { > > > void *data; > > > struct console *next; > > > int level; > > > - struct device classdev; > > > + struct device *classdev; > > > > Ick, no, keep the real structure here. It can properly handle the > > reference counting for the object. Just correctly clean up in the > > release function, not anywhere else. > > Sorry, I'm getting more and more confused about what you're asking me to do, > and less and less clear on the rationale. > > Can you please clarify what "correctly cleaning up" would mean for a > non-pointer `struct device'? > > Is your concern that... > > register_console(c) > device_initialize(c->d) > device_add(c->d) > unregister_console(c) > device_unregister(c->d) console_classdev_release(c->d) > register_console(c) > device_initialize(c->d) <-- classdev was not previously zeroed out > in console_classdev_release() and bad things may happen > > If that's not the point, I could really use some clarification about what > "correctly cleaning up" means for a non-pointer `struct device' :-) The problem is that your release() callback for your class HAS TO clean up the memory for that object. You can not have an empty function, or just say "it will be handled elsewhere." That is the LAST call that will be made when the object is to be freed from memory, as that is when the last reference count is dropped. Anytime before then, you do not know if it is safe to free the memory or not. Does that help? thanks, greg k-h