Message ID | 20240126170901.893-1-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-40399-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2395:b0:106:343:edcb with SMTP id gw21csp15583dyb; Fri, 26 Jan 2024 09:11:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJizJGW0tgDb+xGZCAJKGjhG/cA/bzzD+f/cNr80d5c1IxO07CHbj24yeuDvoLFKrbFklu X-Received: by 2002:a2e:9b87:0:b0:2cd:f047:7890 with SMTP id z7-20020a2e9b87000000b002cdf0477890mr29432lji.210.1706289059870; Fri, 26 Jan 2024 09:10:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706289059; cv=pass; d=google.com; s=arc-20160816; b=X17yuwuGUFDc/y8hh+m7NdGqWje3Jriw0G/rGOMd+rARFgO/4XlUbrFt5D7k9wkmeK 8HN8iRaLDeNr1C6cphOoLqbYG5IG0w7y9lKpbo1GhVT3gvYGUWic+CYoE2GTEXqBRISF MlOzd4jzPICwxCp8r5CwM46iv33iCJR1j8gqrkOnOWmfL+s8AOAzKrJu73ukpKIsn5eA YLR6jefSaJCusVX/A+qmp5RqE8NSWV3sFZt711N7zr+CpVczNmhNvv9GhF12IB3hxJOK oJw/44obEMYJAbjLoxqbgwtuBd8sneN6xjx0V8TW4rhXdyEboaNjP2LI0x9M8mCHY5lB UuqA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=bg3HH+ThJMyAJlUJhLVGp/Wx+XTnNSpgZ6Bzxcok+uc=; fh=nIUXLC4LIPgPybkziEgAGgezA+RhgdKLdgPiv8R2fEQ=; b=pYgIc2rjUVSdGB9xPvtL05sZCpJaNMtWdElajRdYqrnFOdlfPq9wktHCfuAGRjtN3l YsLakhkzyyOaZ4+D4Ei772R/YqsCXyLp/G84+1tcm3gEWWG3E9SnGp5XHOU/vblOrtd+ kklwBIW6u285nSesp/W+P7+/9enB0cvzaRVSet12d407YXODRutbUcM0qZvlvTcvDCc5 TmqoIRrD7quD0WK/ycFjtfrSMnta46tNi8H9ux1KNglw+jrxTbks9jKeWN4I7Duicwh6 i18oMZtEEwwGlsgLRiHeURKRF1dGcp7+3364fiZPdxcjLjguvN/Ow0eJo8DKumN8VGk3 1shA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c73abWvK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-40399-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40399-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id da15-20020a056402176f00b0055c83829f1asi832588edb.392.2024.01.26.09.10.59 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 09:10:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40399-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=c73abWvK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-40399-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40399-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7B6B21F21E2E for <ouuuleilei@gmail.com>; Fri, 26 Jan 2024 17:10:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 433712031A; Fri, 26 Jan 2024 17:10:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c73abWvK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 97E8C200A6; Fri, 26 Jan 2024 17:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706289033; cv=none; b=LJOwKs+yVHR4qx+Y8AHEVOhlEpT4I2wcpZEoyZhNtF82yXglGkImRvwSzNJYWarAQSlYMVKrbgiwva5wzsf+iikrGTW1RKCGymo+ds4gVFLECYX1gKzrZzvc71sFBqlrgWyGyiFFTOgfftAwWZHS76xwlRMOw/R1oo53VYabbhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706289033; c=relaxed/simple; bh=DEHxLqizhVae7GfdD+IYf2Qhwx8aaBFy0kmp5GGvB3M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=h4Bastt7cVJrUyFIif2UWuoTsugGg8zqIpYg20AboMoDJiuyeme4Zw4GF6MqTTxDbyuGIuQ6tiTErpr3Y+RX8HbDmBMdOivzUF4pe7f9XsvnZGXlhAjYMLYENyBOAYeXztYnnNhj96rURy11mpPk77vqbRlNH2rT4TsrmxvfWsw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c73abWvK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69CB1C433C7; Fri, 26 Jan 2024 17:10:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706289033; bh=DEHxLqizhVae7GfdD+IYf2Qhwx8aaBFy0kmp5GGvB3M=; h=From:To:Cc:Subject:Date:From; b=c73abWvKtRcIGlcqIFirNK8ljnzEEB6kiz37s998Hb9Vw0N9xH+v3zXLmRk3Tqyac W3W+4bLnAhkJiG+rCT00MOouACTON12NsDin4kcvSlu8Cm2mvvtB7q1roMj1etB0SZ urBAu1y1mKHVP+ex3XjuPvy4n5R2kzQgWMnNv4DSgqUnICBvu4EANwrwhfAvksmFyE +bQpw7L0KZNXSyRPEV/62g8MFLt30tdHDWjZDfz+ABIUHx1EFZX3iUNbbEMbk8+7zo 4hreBHGf+RMtIKbWcAsf17NBb9lVBjEPQz0xi+29jD1aBMMkk/o2A6uarh2CKlsJqu qi5pR8SDswMAg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from <johan+linaro@kernel.org>) id 1rTPj4-000000000YW-0YGh; Fri, 26 Jan 2024 18:10:46 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <benjamin.tissoires@redhat.com> Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org>, stable@vger.kernel.org, Douglas Anderson <dianders@chromium.org> Subject: [PATCH] HID: i2c-hid-of: fix NULL-deref on failed power up Date: Fri, 26 Jan 2024 18:09:01 +0100 Message-ID: <20240126170901.893-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789173757257317340 X-GMAIL-MSGID: 1789173757257317340 |
Series |
HID: i2c-hid-of: fix NULL-deref on failed power up
|
|
Commit Message
Johan Hovold
Jan. 26, 2024, 5:09 p.m. UTC
A while back the I2C HID implementation was split in an ACPI and OF
part, but the new OF driver never initialises the client pointer which
is dereferenced on power-up failures.
Fixes: b33752c30023 ("HID: i2c-hid: Reorganize so ACPI and OF are separate modules")
Cc: stable@vger.kernel.org # 5.12
Cc: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
---
drivers/hid/i2c-hid/i2c-hid-of.c | 1 +
1 file changed, 1 insertion(+)
Comments
Hi, On Fri, Jan 26, 2024 at 9:10 AM Johan Hovold <johan+linaro@kernel.org> wrote: > > A while back the I2C HID implementation was split in an ACPI and OF > part, but the new OF driver never initialises the client pointer which > is dereferenced on power-up failures. > > Fixes: b33752c30023 ("HID: i2c-hid: Reorganize so ACPI and OF are separate modules") > Cc: stable@vger.kernel.org # 5.12 > Cc: Douglas Anderson <dianders@chromium.org> > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > --- > drivers/hid/i2c-hid/i2c-hid-of.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c > index c4e1fa0273c8..8be4d576da77 100644 > --- a/drivers/hid/i2c-hid/i2c-hid-of.c > +++ b/drivers/hid/i2c-hid/i2c-hid-of.c > @@ -87,6 +87,7 @@ static int i2c_hid_of_probe(struct i2c_client *client) > if (!ihid_of) > return -ENOMEM; > > + ihid_of->client = client; Good catch and thanks for the fix. FWIW, I'd be OK w/ Reviewed-by: Douglas Anderson <dianders@chromium.org> That being said, I'd be even happier if you simply removed the "client" from the structure and removed the error printout. regulator_bulk_enable() already prints error messages when a failure happens and thus the error printout is redundant and wastes space. -Doug
On Fri, 26 Jan 2024, Doug Anderson wrote: > > A while back the I2C HID implementation was split in an ACPI and OF > > part, but the new OF driver never initialises the client pointer which > > is dereferenced on power-up failures. > > > > Fixes: b33752c30023 ("HID: i2c-hid: Reorganize so ACPI and OF are separate modules") > > Cc: stable@vger.kernel.org # 5.12 > > Cc: Douglas Anderson <dianders@chromium.org> > > Signed-off-by: Johan Hovold <johan+linaro@kernel.org> > > --- > > drivers/hid/i2c-hid/i2c-hid-of.c | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c > > index c4e1fa0273c8..8be4d576da77 100644 > > --- a/drivers/hid/i2c-hid/i2c-hid-of.c > > +++ b/drivers/hid/i2c-hid/i2c-hid-of.c > > @@ -87,6 +87,7 @@ static int i2c_hid_of_probe(struct i2c_client *client) > > if (!ihid_of) > > return -ENOMEM; > > > > + ihid_of->client = client; > > Good catch and thanks for the fix. FWIW, I'd be OK w/ > > Reviewed-by: Douglas Anderson <dianders@chromium.org> I've now queued this as a fix for 6.8 .... > That being said, I'd be even happier if you simply removed the "client" > from the structure and removed the error printout. > regulator_bulk_enable() already prints error messages when a failure > happens and thus the error printout is redundant and wastes space. .. and this can be done for 6.9. Thanks,
On Fri, Jan 26, 2024 at 09:47:23AM -0800, Doug Anderson wrote: > On Fri, Jan 26, 2024 at 9:10 AM Johan Hovold <johan+linaro@kernel.org> wrote: > > A while back the I2C HID implementation was split in an ACPI and OF > > part, but the new OF driver never initialises the client pointer which > > is dereferenced on power-up failures. > Good catch and thanks for the fix. FWIW, I'd be OK w/ > > Reviewed-by: Douglas Anderson <dianders@chromium.org> > > That being said, I'd be even happier if you simply removed the > "client" from the structure and removed the error printout. > regulator_bulk_enable() already prints error messages when a failure > happens and thus the error printout is redundant and wastes space. True, but that error message does not include the device that tried to use the regulator. I actually hit this when adding dev_dbg() to the function in question. For such cases, it's also convenient to have struct device easily accessible so I think it should be ok to just leave this pointer in. Johan
diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c index c4e1fa0273c8..8be4d576da77 100644 --- a/drivers/hid/i2c-hid/i2c-hid-of.c +++ b/drivers/hid/i2c-hid/i2c-hid-of.c @@ -87,6 +87,7 @@ static int i2c_hid_of_probe(struct i2c_client *client) if (!ihid_of) return -ENOMEM; + ihid_of->client = client; ihid_of->ops.power_up = i2c_hid_of_power_up; ihid_of->ops.power_down = i2c_hid_of_power_down;