From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 E7647381AE0 for ; Sat, 11 Jul 2026 09:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783761706; cv=none; b=Ttl2SO8gRVQmoqxilAoYeuTBlJIcbXppFwRhRbhpBWlKE6RTYk7HQpHlUpxb4BKoAZJ/S6izybVCB4S7BIuOQiJJsLGqUCM0oox/FUHtLxDi4W9wMD3vSLdDBWpWrf7mOYnTdwiXDbCa2llxSPqF9ZI4TSuO1wiK1NOfqlHKMoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783761706; c=relaxed/simple; bh=uxnE3s+OHBnATD6/J7IwFWikD45wp0+S4wwd8PzleUw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=s0nGBGujrMFaHgVv8Ucv2CfzwJYEBBYAz2kjokgYaHv72LlporBdsSGH1b0uz5Y0UGwf2ds831Xdo3fa7Qy+5p0DsQBQJvuc8NLhU/vd8wYZEbV4eVZ+aiJsJziunbNwvwQKzlSO1MziEO8sOZM+Nr7RqDvrnSHn3DdgPMCPOKY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-84862b0d5aeso1785296b3a.2 for ; Sat, 11 Jul 2026 02:21:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783761702; x=1784366502; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xWPkjt8pFCGFWg9O7q8pVB8rJD2AVw+GyK5aJ4zTUoQ=; b=j5fwno6OJ8IToIh4C/5ybcu/pU/h2AufgCcGyt+GLlnBfODh0ehX96Vla+3ztqvTN8 BhVwaxzcJbw1HmGtKrEGlIjrIdEUzZIfIrELz5Lbi4OjMibZpqgCRNhzK2gijRbGLy0p jk1Ha35o3P/ZIv42Xhcjnr0XFpMRPWrwiBKcGaYB3izZfebzNZ86GotqI9r/R4To14Ym YnJYMzD/BKJLx/V70gW4sM6tQKMafVhKkk5KdVhb10lv8/LxEmI2dbwsuFoz6hQNkiKR HJMZbqqAf2MHIJC0C7ATgwM5buzsiylOej5LTLn2z0yHEFQhtzIZJOoS7ikwfxVUVip1 /7oQ== X-Forwarded-Encrypted: i=1; AHgh+RrD5YpBrnSNHyM2nrtt3WqqI9jswonM+2H+jq7UaD1RVgfhN2u2bUm3dJNnuM8mc35fzig3VFK93BM6gn8=@vger.kernel.org X-Gm-Message-State: AOJu0YyYdmS2+oTaOti74rRk+RCHNCzcf3d3MaD9A1RKJ4HxdNN3Mw+L Qr23uVcbUEPpqyTzDItKApoPwvcH8q0pDmETDNMHg34ZYfMYSIX5/gc= X-Gm-Gg: AfdE7ckg2z0VU18lzfr1P5ygTx3jF1SkmlIcSUBiBGReT/kDda+c56ZVPpgI2p4QAHy ua96bk6RUfmkiGc+rXkKnz5kpFLPGK5OYC7aVPTJzZhtt9OelCy+31qWQ6BoEUAu20FF+CE5B81 uNzLIgcEiMZDsSC4Pdh3oSbEgkBjFixn/oneeMXOps87rmIwXhNx7wkajrvJ0myRGuUoRgW4Ows Xw9DJrBTovBNwXlpMYvLX7BIRjsi1Mio45/JICwSBB0FAuqHYH2JsoQoehjR+vjSsH7/c3nLHVf 5nQVHSznKXr3s5LMzUSDicAxP68yHkRdFdoEf+I5rMLWLuhajL6DA4QsF61iOqlpL5JjCMr2xkc fXqgOXeAQYZ+NnC4zHnRmuUcFiIaHZ6+jVnw0cqanOtJTNLXYh2PYQiLX4Io1vnOXFJ6yLUqraR O10PFcMTbQszxBF7snDZrZD5XUl4DQcESqoAoNRGK2gsvnboS0DwDspVqTCxTV4PyyH3x/DuIcA 1IX/1r3LIap19mmA1MWqR+azw== X-Received: by 2002:a05:6a00:18a0:b0:847:973b:3cf6 with SMTP id d2e1a72fcca58-848894d37e4mr1992859b3a.0.1783761702040; Sat, 11 Jul 2026 02:21:42 -0700 (PDT) Received: from penguin.tail0a1999.ts.net (61-228-52-13.dynamic-ip.hinet.net. [61.228.52.13]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-847f6dbfd41sm11468726b3a.57.2026.07.11.02.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 02:21:41 -0700 (PDT) From: Shih-Yuan Lee To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Shih-Yuan Lee Subject: [PATCH v3 3/3] Input: applespi - fix NULL pointer dereference in tp_dim open Date: Sat, 11 Jul 2026 17:20:54 +0800 Message-Id: <20260711092054.13818-4-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260711092054.13818-1-fourdollars@debian.org> References: <20260711092054.13818-1-fourdollars@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The tp_dim debugfs file is registered synchronously during driver probe in applespi_probe(). However, the applespi->touchpad_input_dev is initialized and registered asynchronously in the driver's worker thread. If a userspace process opens the debugfs file before the worker thread has completed initialization, applespi_tp_dim_open() will dereference the NULL applespi->touchpad_input_dev pointer, causing a kernel panic. Fix this by using smp_load_acquire() to safely load touchpad_input_dev and return -ENODEV if it is not yet initialized. Signed-off-by: Shih-Yuan Lee --- drivers/input/keyboard/applespi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index fd785dba1174..e3e239f430bd 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c @@ -972,12 +972,18 @@ static void applespi_debug_update_dimensions(struct applespi_data *applespi, static int applespi_tp_dim_open(struct inode *inode, struct file *file) { struct applespi_data *applespi = inode->i_private; + struct input_dev *touchpad; file->private_data = applespi; + /* Pairs with smp_store_release in applespi_register_touchpad_device() */ + touchpad = smp_load_acquire(&applespi->touchpad_input_dev); + if (!touchpad) + return -ENODEV; + snprintf(applespi->tp_dim_val, sizeof(applespi->tp_dim_val), "0x%.4x %dx%d+%u+%u\n", - applespi->touchpad_input_dev->id.product, + touchpad->id.product, applespi->tp_dim_min_x, applespi->tp_dim_min_y, applespi->tp_dim_max_x - applespi->tp_dim_min_x, applespi->tp_dim_max_y - applespi->tp_dim_min_y); -- 2.39.5