Re: [PATCH] greybus: Fix deref of NULL in __gb_lights_flash_brightness_set

Михаил Лобанов
2024-03-06T15:29:27Z

Hi Rui, if you can, please prepare a patch with my reported-by tag.
Thanks!

Yours sincerely, Mikhail!

>Hi Mikhail,
>Mikhail Lobanov <m.lobanov@rosalinux.ru> writes:
>
>
>Are you sending a new version with the changes suggested in this thread?
>or do you want me to prepare something with your reported-by tag?
>
>Cheers,
> Rui

> ---
> drivers/staging/greybus/light.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index 87d36948c610..929514350947 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -148,10 +148,15 @@ static int __gb_lights_flash_brightness_set(struct gb_channel *channel)
> GB_CHANNEL_MODE_TORCH);
>
> /* For not flash we need to convert brightness to intensity */
> - intensity = channel->intensity_uA.min +
> +
> + if (channel) {
> + intensity = channel->intensity_uA.min +
> (channel->intensity_uA.step * channel->led->brightness);
>
> - return __gb_lights_flash_intensity_set(channel, intensity);
> + return __gb_lights_flash_intensity_set(channel, intensity);
> + }
> +
> + return 0;
> }
> #else
> static struct gb_channel *get_channel_from_cdev(struct led_classdev *cdev)
> --
> 2.43.0