lkml.org 
[lkml]   [2022]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] leds: max8997: Don't error if there is no pdata
On Thu 2022-10-20 12:44:42, Paul Cercueil wrote:
> The driver works just fine if no platform data is supplied.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Does it? Bad Paul, bad Andy.

> +++ b/drivers/leds/leds-max8997.c
> @@ -238,11 +238,6 @@ static int max8997_led_probe(struct platform_device *pdev)
> char name[20];
> int ret = 0;
>
> - if (pdata == NULL) {
> - dev_err(&pdev->dev, "no platform data\n");
> - return -ENODEV;
> - }
> -
> led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
> if (led == NULL)
> return -ENOMEM;
> @@ -258,7 +253,7 @@ static int max8997_led_probe(struct platform_device *pdev)
> led->iodev = iodev;
>
> /* initialize mode and brightness according to platform_data */
> - if (pdata->led_pdata) {
> + if (pdata && pdata->led_pdata) {
> u8 mode = 0, brightness = 0;
>
> mode = pdata->led_pdata->mode[led->id];

I see pdata being dereferenced here.
Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2022-10-21 15:13    [W:0.044 / U:1.784 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site