Re: [PATCH] platform/x86: intel_mid_powerbtn: Take a copy of ddata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 22, 2020 at 6:06 PM Mika Westerberg
<mika.westerberg@xxxxxxxxxxxxxxx> wrote:
>
> The driver gets driver_data from memory that is marked as const (which
> is probably put to read-only memory) and it then modifies it. This
> likely causes some sort of fault to happen.
>
> Fix this by taking a copy of the structure.
>

Pushed to my review and testing queue, thanks!

> Fixes: c94a8ff14de3 ("platform/x86: intel_mid_powerbtn: make mid_pb_ddata const")
> Signed-off-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> ---
> This was part of the bigger series [1] but I'll send this one separately
> because this is just a simple fix.
>
> [1] https://lkml.org/lkml/2020/1/21/678
>
>  drivers/platform/x86/intel_mid_powerbtn.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/intel_mid_powerbtn.c b/drivers/platform/x86/intel_mid_powerbtn.c
> index 292bace83f1e..6f436836fe50 100644
> --- a/drivers/platform/x86/intel_mid_powerbtn.c
> +++ b/drivers/platform/x86/intel_mid_powerbtn.c
> @@ -146,9 +146,10 @@ static int mid_pb_probe(struct platform_device *pdev)
>
>         input_set_capability(input, EV_KEY, KEY_POWER);
>
> -       ddata = (struct mid_pb_ddata *)id->driver_data;
> +       ddata = devm_kmemdup(&pdev->dev, (void *)id->driver_data,
> +                            sizeof(*ddata), GFP_KERNEL);
>         if (!ddata)
> -               return -ENODATA;
> +               return -ENOMEM;
>
>         ddata->dev = &pdev->dev;
>         ddata->irq = irq;
> --
> 2.24.1
>


-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux