From patchwork Mon Jul 10 14:57:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Thumshirn X-Patchwork-Id: 117956 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp5117383vqx; Mon, 10 Jul 2023 08:50:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlEx1TauhLpEzaxpfftUyVcw/dr9M6sdWnnq//4VN7odMZuombDxd4xDKl4tZnHzUwnR2fxn X-Received: by 2002:a05:6a20:4418:b0:127:5f72:e4dd with SMTP id ce24-20020a056a20441800b001275f72e4ddmr18554870pzb.44.1689004218275; Mon, 10 Jul 2023 08:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689004218; cv=none; d=google.com; s=arc-20160816; b=eq5IOsD6MnQjZls0E0xtXgyBvVe6Az4vsLGeoVydX66tsqo98kb8RgBFZ3owJLppxA +z/F09vAzJwH/0jjaO+M1AhxiOsuaXXWhw5reSG7Lq4J5g3UFGzhJDDLbjt/uu20uUcY reqhK6afRL5tO6pFTh3G0GgGrfUYtEwXvBliBVbstB/QbDvUu4YgxXDfiCsHi7PzmjER 5gV76hAhB5J4rWIHJFsFjQsc93NpWEsueYBbjLjMRmCheZoQAbYZdzAedHPEJ/xwPtGx 2smhtADbytE6hfCw7rf/c+dE1UEwHfyX0TLVQCVPqwRjGADblVV3rW1JxuL0cFQuB0M/ w1Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kWtI3YZPxMpLtWckmqpTfWbdL3C0FhWNd5t88JNq3cE=; fh=h/wwkf09o6uHB+2g8XEuTCAC39FZESweV8/3M1rdE3k=; b=w1OfSS+qfap/C5Lrh4Oj8+vOY8GXRO1+se0MgJTGwYmNeueK5IYpBqvOZ3ezCoqVVm sEm07o22Ylzfh3+sBo2VBHXJXSfHmkwTrrrHtNWi0Oj34k8+V8Rq8VkZs17cJgVdbQrb NWO6cEvqDpMSHy+h/wSGOe/p8xPCu3VX4bABjPlS29KmTlcA4BjiYlyM1Uv4r4Wct31P q3JCUszfXFozy7zgue5wV8f4JdW74VLT6DhqVzjxn7q411aFz+PMpDtcDmb+wz68zIcY UwBOxNtvI8Tleg5qL4PZQ6PpQ+Ns1H+vvSJuaL6VTnJjuX7iUKFlXbsYQiEXEvpPTtiH 1x5Q== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ks14-20020a170903084e00b001b11168655esi44309plb.334.2023.07.10.08.50.04; Mon, 10 Jul 2023 08:50:18 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233318AbjGJO6w (ORCPT + 99 others); Mon, 10 Jul 2023 10:58:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233245AbjGJO6s (ORCPT ); Mon, 10 Jul 2023 10:58:48 -0400 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 185E6127 for ; Mon, 10 Jul 2023 07:58:47 -0700 (PDT) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-3fbf7fbe722so53338085e9.3 for ; Mon, 10 Jul 2023 07:58:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689001125; x=1691593125; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kWtI3YZPxMpLtWckmqpTfWbdL3C0FhWNd5t88JNq3cE=; b=WqetpIGBBwWEhOFmVArSD9jWee/+2OG5iMQqq9ekkRRTF+tNe0mDMeiGcIYux6Y6uZ j85pTV9x/1bF7WMjVfc/HvCylI7WSo6y8JCuw3BJ3h3yLHkxwLb5sQyUnf9U230eyyP9 5FOgjUD2kd0Myat5GAZBQwsP3oM2zhIKR4MV1cz0Y/NGexIVjNWVKWQzQA9IIZxj8/Ap 2+yxoGNfIroczdRox6hL4ELTkcUHOGYh/aePxZ1v8magHqT9DaAk43ZZBgafjB9lJF9q mOJ7tPkJd1HthUJ+iEI05v4cWmv0gQFUcYuvL1Zym951RKw0N+GdqC67zp53zoQ2WoYZ KFiw== X-Gm-Message-State: ABy/qLZpTX4wFE6iHgBIjGUunhR3qwYxaUZ97A34G8e82p7SV9RcZ1AG 2qxGQ8uBavt1LbyquwsYmxE= X-Received: by 2002:a7b:c84c:0:b0:3fa:7b44:7195 with SMTP id c12-20020a7bc84c000000b003fa7b447195mr15654712wml.10.1689001125337; Mon, 10 Jul 2023 07:58:45 -0700 (PDT) Received: from localhost.localdomain (aftr-62-216-205-175.dynamic.mnet-online.de. [62.216.205.175]) by smtp.googlemail.com with ESMTPSA id y6-20020a05600c364600b003fc16ee2864sm47920wmq.48.2023.07.10.07.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 07:58:44 -0700 (PDT) From: Johannes Thumshirn To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, =?utf-8?q?Rodr=C3=ADguez_Barbarin=2C_Jos?= =?utf-8?q?=C3=A9_Javier?= , Jorge Sanjuan Garcia , Javier Rodriguez , Johannes Thumshirn Subject: [PATCH 1/1] mcb: Do not add the mcb_bus_type to the mcb_bus itself Date: Mon, 10 Jul 2023 16:57:52 +0200 Message-Id: <20230710145752.14285-2-jth@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230710145752.14285-1-jth@kernel.org> References: <20230710145752.14285-1-jth@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,RCVD_IN_SORBS_WEB, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771048630744983178 X-GMAIL-MSGID: 1771049287148881607 From: Rodríguez Barbarin, José Javier When allocating a new mcb_bus the bus_type is added to the mcb_bus itself, causing an issue when calling mcb_bus_add_devices(). This function is not only called for each mcb_device under the mcb_bus but for the bus itself. This causes a crash when freeing the ida resources as the bus numbering gets corrupted due to a wrong cast of structs mcb_bus and mcb_device. Make the release of the mcb devices and their mcb bus explicit. Co-developed-by: Jorge Sanjuan Garcia Signed-off-by: Jorge Sanjuan Garcia Signed-off-by: Javier Rodriguez Signed-off-by: Johannes Thumshirn --- drivers/mcb/mcb-core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c index 978fdfc19a06..d4535b8aea1d 100644 --- a/drivers/mcb/mcb-core.c +++ b/drivers/mcb/mcb-core.c @@ -251,6 +251,12 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev) } EXPORT_SYMBOL_NS_GPL(mcb_device_register, MCB); + +static void mcb_bus_unregister(struct mcb_bus *bus) +{ + device_unregister(&bus->dev); +} + static void mcb_free_bus(struct device *dev) { struct mcb_bus *bus = to_mcb_bus(dev); @@ -286,7 +292,6 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier) device_initialize(&bus->dev); bus->dev.parent = carrier; - bus->dev.bus = &mcb_bus_type; bus->dev.type = &mcb_carrier_device_type; bus->dev.release = &mcb_free_bus; @@ -322,6 +327,7 @@ static void mcb_devices_unregister(struct mcb_bus *bus) void mcb_release_bus(struct mcb_bus *bus) { mcb_devices_unregister(bus); + mcb_bus_unregister(bus); } EXPORT_SYMBOL_NS_GPL(mcb_release_bus, MCB);