From: William Breathitt Gray <vilhelm.gray@gmail.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: linux-kernel@vger.kernel.org,
Pengutronix Kernel Team <kernel@pengutronix.de>,
David Jander <david@protonic.nl>,
Robin van der Gracht <robin@protonic.nl>,
linux-iio@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
u.kleine-koenig@pengutronix.de
Subject: Re: [PATCH v1] counter: fix NULL pointer dereference on counter_comp_u8_store()
Date: Fri, 4 Feb 2022 16:02:11 +0900 [thread overview]
Message-ID: <YfzPcyusGwAOkys6@shinobu> (raw)
In-Reply-To: <20220203135418.2252624-1-o.rempel@pengutronix.de>
[-- Attachment #1: Type: text/plain, Size: 1731 bytes --]
On Thu, Feb 03, 2022 at 02:54:18PM +0100, Oleksij Rempel wrote:
> Current kernel will report NULL pointer dereference with following
> back trace:
> interrupt_cnt_enable_write from counter_comp_u8_store+0xc0/0xf4
> counter_comp_u8_store from dev_attr_store+0x24/0x30
> dev_attr_store from sysfs_kf_write+0x48/0x54
> sysfs_kf_write from kernfs_fop_write_iter+0x128/0x1c8
> kernfs_fop_write_iter from vfs_write+0x124/0x1b4
> vfs_write from ksys_write+0x88/0xe0
> ksys_write from sys_write+0x18/0x1c
> sys_write from ret_fast_syscall+0x0/0x1c
>
> Add missing dev_set_drvdata() to fix it.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Hi Oleksij,
This dev_set_drvdata() was removed in commit b56346ddbd82 ("counter: Use
container_of instead of drvdata to track counter_device"). It looks like
we overlooked the counter-sysfs.c file when we made that change.
Would you instead replace the dev_get_drvdata() calls in counter-sysfs.c
with respective container_of() calls? Add a Fixes tag referencing commit
b56346ddbd82 as well to your commit message.
Thanks,
William Breathitt Gray
> ---
> drivers/counter/counter-core.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/counter/counter-core.c b/drivers/counter/counter-core.c
> index 7e0957eea094..1de16d5e9fbc 100644
> --- a/drivers/counter/counter-core.c
> +++ b/drivers/counter/counter-core.c
> @@ -98,6 +98,8 @@ struct counter_device *counter_alloc(size_t sizeof_priv)
> counter = &ch->counter;
> dev = &counter->dev;
>
> + dev_set_drvdata(dev, counter);
> +
> /* Acquire unique ID */
> err = ida_alloc(&counter_ida, GFP_KERNEL);
> if (err < 0)
> --
> 2.30.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-02-04 7:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-03 13:54 [PATCH v1] counter: fix NULL pointer dereference on counter_comp_u8_store() Oleksij Rempel
2022-02-04 7:02 ` William Breathitt Gray [this message]
2022-02-04 8:25 ` [PATCH] counter: Stop using dev_get_drvdata() to get the counter device Uwe Kleine-König
2022-02-08 1:42 ` William Breathitt Gray
2022-02-17 14:48 ` Jarkko Nikula
2022-02-17 16:03 ` Uwe Kleine-König
2022-02-17 23:42 ` William Breathitt Gray
2022-02-18 7:47 ` Uwe Kleine-König
2022-02-18 9:11 ` William Breathitt Gray
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YfzPcyusGwAOkys6@shinobu \
--to=vilhelm.gray@gmail.com \
--cc=david@protonic.nl \
--cc=jic23@kernel.org \
--cc=kernel@pengutronix.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=robin@protonic.nl \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox