From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A781944C653 for ; Wed, 15 Jul 2026 12:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118116; cv=none; b=TTDzNsDI3oJ8JWKC3h5Lg0mhndG90lOdXMn0lHndB4yUyciosfATBL4HVC7zJXDQAjY1iq/P/xWBKZgtQ0q3GFkuYnYTfAqtAJT0EyQWAjBLr/O8EbVDSsd+BxfUbJvqVwhhwmVgOVPCPYXYAP5vwAJrOEx/hK9NkZhXEBh8+OI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784118116; c=relaxed/simple; bh=27+I1n8CCrlAppK7FavKpCDgL8Oz7SRSvXW4jCFhQeA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=AD4RoLWxG2HnMD/0Z3hsaKUguZ7Z5YkxYkWaseYDpgGO80ePXDfYfvPS44kX8oNOsxSifjzjy+q74cLoyYS8v+d0LDFR2bkUc9R7GOr8+Um3oc6CXqIk/iJijQl6GaU5UJq8EJEjYrkedYxZcNxf5F7Ftu/m4NusFLeR6uMNZV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=efynYqp1; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--songguo.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="efynYqp1" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-493a7fa8481so4467525e9.1 for ; Wed, 15 Jul 2026 05:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784118113; x=1784722913; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=RytOD9QI2NCJQSiSLFVG72euBbLNbvbdAxJ/RIBJjJg=; b=efynYqp1QRarP0yWr0uK/RlAR6obk2snf6qj+3pU+E15pqESrgXEgVQhWELf/KyNRl 9Gm3QmMykXkxcMYzFIpTg+rUQ2q8kBtyi3+WscWzvL49yUmrRNAVgwXXQWQVunEEaK3H ozIvGXFi4Wuo4LQqF/iHgXI9Dwub3r2pcNOkfP1uE6vA+ISA1kzanb7YiH7bKQItbj1O G8Gd5O6i/haCjKZmYzW7XIEhgxWFKGeqq+9vwwL4kQcui268OGQDKNCrM7nKI16SJOMu notXx3hwDmW0pjgZqrORDe3YtZtWZaXnuZzlpTV00g3xFNIEQi1LpvDNel84ZP099uAV bTZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784118113; x=1784722913; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RytOD9QI2NCJQSiSLFVG72euBbLNbvbdAxJ/RIBJjJg=; b=Hvpq0oHSDliOMcSKCbB9ZyA77m/cALJaXqRWjGSoHPJ723ZXYSrHxbzGeY/gkgu42L 7GKp/VpZhihDDPOyNF3LrciZnVYzCJzIBperxZlhUuZTVjNRSJi15WP/k42AelLo4br0 MSvQWwIvr5enWfi6sDY7IzQAZqDJETKfVf6G3kYE20t/w+h6m30EAUEmCpphO3ZQA2Zt FZdKSXnbASOZqFJsKqAXNoCjmJR6lLD9rm10U4Gt2OpKQaXZgGR/PYi6gtxRi4vWkkL2 4GQO/+pa5/VXkaaqLn+8XdPz4o/iUXWDW+XsUGbHlqKCbrhgU2IXhzTK6SwLUVunJltN HpEQ== X-Forwarded-Encrypted: i=1; AHgh+RqsLKAvNrB4C168ZUU4lG7+hl4dJmQ+MmSaLpaFoGx/OoAAA7PqcBfm8tLpt5+p8IUgL+nIcyo5/jSwSMs=@vger.kernel.org X-Gm-Message-State: AOJu0YyQIdLMUq/2GvQwkvXJKSSM/uutokTR0uK1hgZCOpXuW8yYduWl ZQi4MXSeOeBbfsv9Wn4eRl/EHIiORzOHquS36enwtV1iiUm6UQculiXDuMg/2fNBAmmSL5YF1BG l/kzYuttn2Q== X-Received: from wmiv11.prod.google.com ([2002:a05:600c:e40b:b0:493:ab17:3e61]) (user=songguo job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600d:8444:20b0:493:e2c3:af25 with SMTP id 5b1f17b1804b1-493f88bd90emr140028105e9.12.1784118112588; Wed, 15 Jul 2026 05:21:52 -0700 (PDT) Date: Wed, 15 Jul 2026 12:21:44 +0000 In-Reply-To: <20260715122146.4069884-1-songguo@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260715122146.4069884-1-songguo@google.com> X-Mailer: git-send-email 2.55.0.141.g00534a21ce-goog Message-ID: <20260715122146.4069884-2-songguo@google.com> Subject: [PATCH v2 1/3] misc: open-dice: do not assume dev->of_node is valid From: Song Guo To: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: Song Guo Content-Type: text/plain; charset="UTF-8" dev->of_node is not null only when the device is configured via device tree. When the matching device is configured by other means (like ACPI), the current code will cause null pointer dereference. Signed-off-by: Song Guo --- drivers/misc/open-dice.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/misc/open-dice.c b/drivers/misc/open-dice.c index 45060fb4ea27..094b24dfc6ea 100644 --- a/drivers/misc/open-dice.c +++ b/drivers/misc/open-dice.c @@ -118,13 +118,18 @@ static int __init open_dice_probe(struct platform_device *pdev) { static unsigned int dev_idx; struct device *dev = &pdev->dev; - struct reserved_mem *rmem; + struct reserved_mem *rmem = NULL; struct open_dice_drvdata *drvdata; int ret; - rmem = of_reserved_mem_lookup(dev->of_node); - if (!rmem) { - dev_err(dev, "failed to lookup reserved memory\n"); + if (dev->of_node) { + rmem = of_reserved_mem_lookup(dev->of_node); + if (!rmem) { + dev_err(dev, "failed to lookup reserved memory\n"); + return -EINVAL; + } + } else { + dev_err(dev, "device not supported (no DT node)\n"); return -EINVAL; } -- 2.55.0.141.g00534a21ce-goog