From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47EEDC32774 for ; Tue, 23 Aug 2022 06:52:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240124AbiHWGw4 (ORCPT ); Tue, 23 Aug 2022 02:52:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240281AbiHWGwu (ORCPT ); Tue, 23 Aug 2022 02:52:50 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4513332EF3; Mon, 22 Aug 2022 23:52:49 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EFAAA5CE1E; Tue, 23 Aug 2022 06:52:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1661237567; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eYMUmh3kdNOx/JaLg/c+3cGzbIYGUPtDELdhrr+d+x0=; b=dXpummimcpoPVeSiAMUCQVlo0x9m5vOtV1PPAFCoqZnvEXrB3yzpQrWhzG8zcn2ym4vPMv XhB01foh5uB/LHUphrNuPpLS+R1rpbkqQbD+/HDyw3Y4n0i16n07ijUTYwi/beVK5lwq3Y bMwK3GSwQN6IgSmI3imN7hINSb+5ulI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1661237567; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eYMUmh3kdNOx/JaLg/c+3cGzbIYGUPtDELdhrr+d+x0=; b=KlncozW2rbC3eoyT8fhyE7DYkujQdEcvPiDQmMbUEF6iF0iougn1Kv2WQjqwqewIPE5MY6 pegHOvUvqwU+3aDA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C65AE13A89; Tue, 23 Aug 2022 06:52:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2LypLz95BGPTLwAAMHmgww (envelope-from ); Tue, 23 Aug 2022 06:52:47 +0000 Date: Tue, 23 Aug 2022 08:52:47 +0200 Message-ID: <87czcrsb7k.wl-tiwai@suse.de> From: Takashi Iwai To: Greg Kroah-Hartman Cc: Linyu Yuan , Heikki Krogerus , Takashi Iwai , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [REGRESSION 5.19] NULL dereference by ucsi_acpi driver In-Reply-To: References: <87r11cmbx0.wl-tiwai@suse.de> <5e17fc89-6056-076c-0c4e-dac7f312792c@quicinc.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 23 Aug 2022 08:41:00 +0200, Greg Kroah-Hartman wrote: > > On Tue, Aug 23, 2022 at 10:26:59AM +0800, Linyu Yuan wrote: > > > > On 8/22/2022 9:24 PM, Heikki Krogerus wrote: > > > Hi, > > > > > > On Sat, Aug 20, 2022 at 08:40:52PM +0200, Greg Kroah-Hartman wrote: > > > > On Fri, Aug 19, 2022 at 06:32:43PM +0200, Takashi Iwai wrote: > > > > > Hi, > > > > > > > > > > we've got multiple reports about 5.19 kernel starting crashing after > > > > > some time, and this turned out to be triggered by ucsi_acpi driver. > > > > > The details are found in: > > > > > https://bugzilla.suse.com/show_bug.cgi?id=1202386 > > > > > > > > > > The culprit seems to be the commit 87d0e2f41b8c > > > > > usb: typec: ucsi: add a common function ucsi_unregister_connectors() > > > > Adding Heikki to the thread... > > > > > > > > > This commit looks as if it were a harmless cleanup, but this failed in > > > > > a subtle way. Namely, in the error scenario, the driver gets an error > > > > > at ucsi_register_altmodes(), and goes to the error handling to release > > > > > the resources. Through this refactoring, the release part was unified > > > > > to a funciton ucsi_unregister_connectors(). And there, it has a NULL > > > > > check of con->wq, and it bails out the loop if it's NULL. > > > > > Meanwhile, ucsi_register_port() itself still calls destroy_workqueue() > > > > > and clear con->wq at its error path. This ended up in the leftover > > > > > power supply device with the uninitialized / cleared device. > > > > > > > > > > It was confirmed that the problem could be avoided by a simple > > > > > revert. > > > > I'll be glad to revert this now, unless Heikki thinks: > > > > > > > > > I guess another fix could be removing the part clearing con->wq, i.e. > > > > > > > > > > --- a/drivers/usb/typec/ucsi/ucsi.c > > > > > +++ b/drivers/usb/typec/ucsi/ucsi.c > > > > > @@ -1192,11 +1192,6 @@ static int ucsi_register_port(struct ucsi *ucsi, int index) > > > > > out_unlock: > > > > > mutex_unlock(&con->lock); > > > > > - if (ret && con->wq) { > > > > > - destroy_workqueue(con->wq); > > > > > - con->wq = NULL; > > > > > - } > > > > > - > > > > > return ret; > > > > > } > > > > > > > > > > ... but it's totally untested and I'm not entirely sure whether it's > > > > > better. > > > > that is any better? > > > No, I don't think that's better. Right now I would prefer that we play > > > it safe and revert. > > > > > > The conditions are different in the two places where the ports are > > > unregistered in this driver. Therefore I don't think it makes sense > > > to use a function like ucsi_unregister_connectors() that tries to > > > cover both cases. It will always be a little bit fragile. > > > > > > Instead we could introduce a function that can be used to remove a > > > single port. That would leave the handling of the conditions to the > > > callers of the function, but it would still remove the boilerplate. > > > That would be much safer IMO. > > > > > > But to fix this problem, I think we should revert. > > > > but revert will happen on several stable branch, right ? > > If someone sends it to me, yes :) > > {hint} OK, will submit :) Takashi