From patchwork Fri Aug 19 16:32:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 598733 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 774D2C28B2B for ; Fri, 19 Aug 2022 17:13:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351057AbiHSRNG (ORCPT ); Fri, 19 Aug 2022 13:13:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350057AbiHSRMr (ORCPT ); Fri, 19 Aug 2022 13:12:47 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 068FE11E929; Fri, 19 Aug 2022 09:32:45 -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 2F2C120020; Fri, 19 Aug 2022 16:32:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1660926764; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=Q2pLXvlU5YgHaptan5BWvmSxGKks847fO3qHv94Cm9Q=; b=kvHiRkoxnvdE/i6OGkLnvWUlxvnxcOhdMiymht7uikU22JdUHmuW38ZyG0Xd2aMVCQzeTE 0QNIq6+s7d5m0VikvSLuohZafIpJ8HakpRLEKF5VGXVJEQtTwyBuFkF2y4ZFr5WJl1lUZb dRGGw0ob9aNGyIyKrMFAv/Op713NfG4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1660926764; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type; bh=Q2pLXvlU5YgHaptan5BWvmSxGKks847fO3qHv94Cm9Q=; b=wQxQTa/eeS/24YYJTxCI5Opt9Z63dB5dtfn8/xRe8h3YoMxOUJE1nqbal2Zu+wPzwE6prk z8Zv7oDmU2hR5uAQ== 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 0C0F813AC1; Fri, 19 Aug 2022 16:32:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id DnENAiy7/2JqJgAAMHmgww (envelope-from ); Fri, 19 Aug 2022 16:32:44 +0000 Date: Fri, 19 Aug 2022 18:32:43 +0200 Message-ID: <87r11cmbx0.wl-tiwai@suse.de> From: Takashi Iwai To: Greg Kroah-Hartman Cc: Linyu Yuan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [REGRESSION 5.19] NULL dereference by ucsi_acpi driver 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") Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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() 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 guess another fix could be removing the part clearing con->wq, i.e. ... but it's totally untested and I'm not entirely sure whether it's better. thanks, Takashi --- 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; }