From patchwork Mon Dec 9 22:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 13900450 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7452319C54C for ; Mon, 9 Dec 2024 22:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733781935; cv=none; b=QXmM+Rn+N/l2lXQHE6/lI6lIS4sS46G/WZ8x3gFylIwavoE0XDqySM9RQtwRUR3/zTDlVZg0D2FAJ8Iua7ughCZn+zUPnTgKkbcpF8Oz+vV664AX6PLpN2oKYf4g6BW/vt5siLBOWAem0G+7/bQB7j/9JdK72C4qUIo6No9wxyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733781935; c=relaxed/simple; bh=Aj9j0Jhp/boH81DZLsgKLqumciNts4Gm+6quYDJdug0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QcfqGJ3oP6FgHZbpPV8PfUqOSGDOPNCqm1wWoOYgV4baQcxpsqP4aRFUwAx640OdT9+PTggmZti0S64puWOnvE62JenzaAXyAKmygkoYbeDFsLnqZ+EPycltHl5cZQrX/g18kUySlNYRgxAGkunaeqtrJ+Q72H/d/qXBHde7yv4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=bvPi8DuE; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="bvPi8DuE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733781932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0m4Vuodr9OU6acTTUVglkcuEGxIwPVWrhRDwLTDpOAc=; b=bvPi8DuEo3bUVbnj+0GdPCw0TIX/W2/u3bxog0TuHE1IKq1ycI2fb2BTAxqhvRUOjNRmsr V0/57iUDVUMGJDoomLgjZUEbneHa8Du1ekLqkJZW3idOn7NgyJwkR1FHzxXmXSxGe9tBAW MmElTX4d9nEO7OkEX+xFTAutZLgE+5Y= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-xBssw4krN4Oos9mPYg7aMg-1; Mon, 09 Dec 2024 17:05:26 -0500 X-MC-Unique: xBssw4krN4Oos9mPYg7aMg-1 X-Mimecast-MFC-AGG-ID: xBssw4krN4Oos9mPYg7aMg Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5F4D01955F45; Mon, 9 Dec 2024 22:05:25 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.192.3]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0D60019560A7; Mon, 9 Dec 2024 22:05:23 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , platform-driver-x86@vger.kernel.org Subject: [PATCH v2 1/4] platform/x86: int3472: Check for adev == NULL Date: Mon, 9 Dec 2024 23:05:19 +0100 Message-ID: <20241209220522.25288-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Not all devices have an ACPI companion fwnode, so adev might be NULL. This can e.g. (theoretically) happen when a user manually binds one of the int3472 drivers to another i2c/platform device through sysfs. Add a check for adev not being set and return -ENODEV in that case to avoid a possible NULL pointer deref in skl_int3472_get_acpi_buffer(). Signed-off-by: Hans de Goede --- Changes in v2: - Improve commit message --- drivers/platform/x86/intel/int3472/discrete.c | 3 +++ drivers/platform/x86/intel/int3472/tps68470.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index d881b2cfcdfc..09fff213b091 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -336,6 +336,9 @@ static int skl_int3472_discrete_probe(struct platform_device *pdev) struct int3472_cldb cldb; int ret; + if (!adev) + return -ENODEV; + ret = skl_int3472_fill_cldb(adev, &cldb); if (ret) { dev_err(&pdev->dev, "Couldn't fill CLDB structure\n"); diff --git a/drivers/platform/x86/intel/int3472/tps68470.c b/drivers/platform/x86/intel/int3472/tps68470.c index 1e107fd49f82..81ac4c691963 100644 --- a/drivers/platform/x86/intel/int3472/tps68470.c +++ b/drivers/platform/x86/intel/int3472/tps68470.c @@ -152,6 +152,9 @@ static int skl_int3472_tps68470_probe(struct i2c_client *client) int ret; int i; + if (!adev) + return -ENODEV; + n_consumers = skl_int3472_fill_clk_pdata(&client->dev, &clk_pdata); if (n_consumers < 0) return n_consumers;