* [PATCH] Input: cyttsp4_core: fix use after free bug
@ 2019-11-05 6:46 Pan Bian
2019-11-13 1:04 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2019-11-05 6:46 UTC (permalink / raw)
To: Ferruh Yigit, Dmitry Torokhov; +Cc: linux-input, linux-kernel, Pan Bian
The device md->input is used after it is released. Setting the device
data to NULL is unnecessary as the device is never used again. Instead,
md->input should be assigned NULL to avoid accessing the freed memory
accidently. Besides, checking md->si against NULL is superfluous as it
points to a variable address, which cannot be NULL.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/input/touchscreen/cyttsp4_core.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index 4b22d49a0f49..2cd5f835665e 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -1990,11 +1990,6 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd)
/* get sysinfo */
md->si = &cd->sysinfo;
- if (!md->si) {
- dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n",
- __func__, md->si);
- goto error_get_sysinfo;
- }
rc = cyttsp4_setup_input_device(cd);
if (rc)
@@ -2004,8 +1999,7 @@ static int cyttsp4_mt_probe(struct cyttsp4 *cd)
error_init_input:
input_free_device(md->input);
-error_get_sysinfo:
- input_set_drvdata(md->input, NULL);
+ md->input = NULL;
error_alloc_failed:
dev_err(dev, "%s failed.\n", __func__);
return rc;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Input: cyttsp4_core: fix use after free bug
2019-11-05 6:46 [PATCH] Input: cyttsp4_core: fix use after free bug Pan Bian
@ 2019-11-13 1:04 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2019-11-13 1:04 UTC (permalink / raw)
To: Pan Bian; +Cc: Ferruh Yigit, linux-input, linux-kernel
On Tue, Nov 05, 2019 at 02:46:19PM +0800, Pan Bian wrote:
> The device md->input is used after it is released. Setting the device
> data to NULL is unnecessary as the device is never used again. Instead,
> md->input should be assigned NULL to avoid accessing the freed memory
> accidently.
No, we are tearing up the device anyway, I'd leave it as it was, so I'll
drop this chunk and apply the rest.
Thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-13 1:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05 6:46 [PATCH] Input: cyttsp4_core: fix use after free bug Pan Bian
2019-11-13 1:04 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).