linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]  iio: adc: exynos-adc: Fix NULL pointer exception on unbind
@ 2019-02-08 23:39 Krzysztof Kozlowski
  2019-02-09 16:47 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2019-02-08 23:39 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Kukjin Kim, Krzysztof Kozlowski,
	Jonathan Bakker, Paweł Chmiel, linux-iio, linux-arm-kernel,
	linux-samsung-soc, linux-kernel
  Cc: stable

Fix NULL pointer exception on device unbind when device tree does not
contain "has-touchscreen" property.  In such case the input device is
not registered so it should not be unregistered.

    $ echo "12d10000.adc" > /sys/bus/platform/drivers/exynos-adc/unbind

    Unable to handle kernel NULL pointer dereference at virtual address 00000474
    ...
    (input_unregister_device) from [<c0772060>] (exynos_adc_remove+0x20/0x80)
    (exynos_adc_remove) from [<c0587d5c>] (platform_drv_remove+0x20/0x40)
    (platform_drv_remove) from [<c05860f0>] (device_release_driver_internal+0xdc/0x1ac)
    (device_release_driver_internal) from [<c0583ecc>] (unbind_store+0x60/0xd4)
    (unbind_store) from [<c031b89c>] (kernfs_fop_write+0x100/0x1e0)
    (kernfs_fop_write) from [<c029709c>] (__vfs_write+0x2c/0x17c)
    (__vfs_write) from [<c0297374>] (vfs_write+0xa4/0x184)
    (vfs_write) from [<c0297594>] (ksys_write+0x4c/0xac)
    (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)

Fixes: 2bb8ad9b44c5 ("iio: exynos-adc: add experimental touchscreen support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 drivers/iio/adc/exynos_adc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index fa2d2b5767f3..41da522fc673 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -929,7 +929,7 @@ static int exynos_adc_remove(struct platform_device *pdev)
 	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
 	struct exynos_adc *info = iio_priv(indio_dev);
 
-	if (IS_REACHABLE(CONFIG_INPUT)) {
+	if (IS_REACHABLE(CONFIG_INPUT) && info->input) {
 		free_irq(info->tsirq, info);
 		input_unregister_device(info->input);
 	}
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH]  iio: adc: exynos-adc: Fix NULL pointer exception on unbind
  2019-02-08 23:39 [PATCH] iio: adc: exynos-adc: Fix NULL pointer exception on unbind Krzysztof Kozlowski
@ 2019-02-09 16:47 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2019-02-09 16:47 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Lars-Peter Clausen, linux-iio, Jonathan Bakker, linux-kernel,
	stable, linux-samsung-soc, Kukjin Kim, Peter Meerwald-Stadler,
	Hartmut Knaack, linux-arm-kernel, Paweł Chmiel

On Sat,  9 Feb 2019 00:39:27 +0100
Krzysztof Kozlowski <krzk@kernel.org> wrote:

> Fix NULL pointer exception on device unbind when device tree does not
> contain "has-touchscreen" property.  In such case the input device is
> not registered so it should not be unregistered.
> 
>     $ echo "12d10000.adc" > /sys/bus/platform/drivers/exynos-adc/unbind
> 
>     Unable to handle kernel NULL pointer dereference at virtual address 00000474
>     ...
>     (input_unregister_device) from [<c0772060>] (exynos_adc_remove+0x20/0x80)
>     (exynos_adc_remove) from [<c0587d5c>] (platform_drv_remove+0x20/0x40)
>     (platform_drv_remove) from [<c05860f0>] (device_release_driver_internal+0xdc/0x1ac)
>     (device_release_driver_internal) from [<c0583ecc>] (unbind_store+0x60/0xd4)
>     (unbind_store) from [<c031b89c>] (kernfs_fop_write+0x100/0x1e0)
>     (kernfs_fop_write) from [<c029709c>] (__vfs_write+0x2c/0x17c)
>     (__vfs_write) from [<c0297374>] (vfs_write+0xa4/0x184)
>     (vfs_write) from [<c0297594>] (ksys_write+0x4c/0xac)
>     (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
> 
> Fixes: 2bb8ad9b44c5 ("iio: exynos-adc: add experimental touchscreen support")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Given we have had this one for a little while and are late in the
cycle I'm going to queue it up for the coming merge window.

Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/exynos_adc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index fa2d2b5767f3..41da522fc673 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -929,7 +929,7 @@ static int exynos_adc_remove(struct platform_device *pdev)
>  	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>  	struct exynos_adc *info = iio_priv(indio_dev);
>  
> -	if (IS_REACHABLE(CONFIG_INPUT)) {
> +	if (IS_REACHABLE(CONFIG_INPUT) && info->input) {
>  		free_irq(info->tsirq, info);
>  		input_unregister_device(info->input);
>  	}


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-09 16:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-08 23:39 [PATCH] iio: adc: exynos-adc: Fix NULL pointer exception on unbind Krzysztof Kozlowski
2019-02-09 16:47 ` Jonathan Cameron

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).