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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACA20C433F5 for ; Sun, 9 Oct 2022 03:33:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0C41A84BD8; Sun, 9 Oct 2022 05:33:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lqgFK2V9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 974D684DD0; Sun, 9 Oct 2022 05:33:35 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CAD0C84DE8 for ; Sun, 9 Oct 2022 05:33:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd32.google.com with SMTP id y4so1735329iof.3 for ; Sat, 08 Oct 2022 20:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YkVHePJ+21JWbWZJVWr94gVjJ2tAeNPBNdi6rp2pNPU=; b=lqgFK2V9F2yz737dRf+ZEk8I59Zsjvm38vmuDJ1xBaJau84Ocyna9Pel49F68amBrx aVA7DiBNSH8dKOWBYjnlSnk2IuUF/UAZN+aaDb53ZlxaXH045NO+0CNxGRYmSb5UtYCO Fhxxvo8CowTi/s2k1eEvHD5Q6uyAbnEBis6oI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=YkVHePJ+21JWbWZJVWr94gVjJ2tAeNPBNdi6rp2pNPU=; b=nlTjkMu+CiSf+a2Rf7PmyEAoQF56Bh3BRoXXiPkaYN8b5lFU6qQAWndJgoiDsd5nL6 l5DfO4V39xYqv3mfJ6G0IiWNX8QDlZ97YxgYmtXzuU67Y3ee8fIFS1JIPSqaSN8/+KfZ b0dCYSjw0GcV2U1jXDUuxP87x8qWU0qsBu+loryZSV/EBXXnTG3gEe6pdwKfUlzHMPJj 6lHT3E7EIW0nneIWnXbytD8xHwzjm6RIRxep0o+DunR/N9opq3HIWqeqQHAjQyBULFQ7 oQoj77MYEJiksghwKRrdLamIGShCSCsXamw/41KSrJVOgZ6u1H0GnXqMXXmBHBmQ0Fkl /fzw== X-Gm-Message-State: ACrzQf23svjYgKh8aXdCz9ZWPgtq8nt3hkP4bl0AZPahIC3ZdvI+Clgl mA5WDWvSHdBWZ24Jt4l8M/EOP52LglCrJQ== X-Google-Smtp-Source: AMsMyM6hNuxE7mR5NuPkoN/SHZc7xoKnqMlq+7y9X5PNFejmcwzS/i4ct/zBImXt5sPBTcjYm+XJqw== X-Received: by 2002:a05:6638:1c08:b0:35b:1319:2d9e with SMTP id ca8-20020a0566381c0800b0035b13192d9emr6335503jab.233.1665286408865; Sat, 08 Oct 2022 20:33:28 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id cn24-20020a0566383a1800b0035a648fd47csm2623241jab.61.2022.10.08.20.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Oct 2022 20:33:28 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 1/3] dm: core: Fix lists_bind_fdt() using non-existent of_match Date: Sat, 8 Oct 2022 21:33:20 -0600 Message-Id: <20221009033322.482812-2-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221009033322.482812-1-sjg@chromium.org> References: <20221009033322.482812-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean The call to device_bind_with_driver_data() passes id->data but if the entry has no of_match then the id has not been set by the selected driver. Normally this passes unnoticed since a previous driver likely had an of_match value, so the id is set to that. Of course it is not correct to pass the id->data from a different driver. With clang-14 the driver ordering is such that the id is never actually set in the 'bind /usb@1 usb_ether' line in test_bind_unbind_with_node() thus causing a crash. Fix this by passing 0 if the of_match for a driver does not exist. Signed-off-by: Simon Glass --- drivers/core/lists.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/core/lists.c b/drivers/core/lists.c index c49695b24f0..3878957c9ef 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -222,6 +222,7 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, log_debug(" - attempt to match compatible string '%s'\n", compat); + id = NULL; for (entry = driver; entry != driver + n_ents; entry++) { if (drv) { if (drv != entry) @@ -250,7 +251,8 @@ int lists_bind_fdt(struct udevice *parent, ofnode node, struct udevice **devp, entry->name, entry->of_match->compatible, id->compatible); ret = device_bind_with_driver_data(parent, entry, name, - id->data, node, &dev); + id ? id->data : 0, node, + &dev); if (ret == -ENODEV) { log_debug("Driver '%s' refuses to bind\n", entry->name); continue; -- 2.38.0.rc1.362.ged0d419d3c-goog