public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Alex Elder <elder@ieee.org>
To: Rui Miguel Silva <rmfrfs@gmail.com>,
	Dan Carpenter <dan.carpenter@linaro.org>
Cc: Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] staging: greybus: fix get_channel_from_mode() failure path
Date: Mon, 4 Mar 2024 11:49:53 -0600	[thread overview]
Message-ID: <1c77c0ef-c098-4962-909d-6bf53cdbde60@ieee.org> (raw)
In-Reply-To: <m3sf16tky7.fsf@gmail.com>

On 3/4/24 3:17 AM, Rui Miguel Silva wrote:
> Hi Dan,
> once again thanks for the patch.
> 
> Dan Carpenter <dan.carpenter@linaro.org> writes:
> 
>> The get_channel_from_mode() function is supposed to return the channel
>> which matches the mode.  But it has a bug where if it doesn't find a
>> matching channel then it returns the last channel.  It should return
>> NULL instead.
>>
>> Also remove an unnecessary NULL check on "channel".
>>
>> Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
>> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 
> Reviewed-by: Rui Miguel Silva <rmfrfs@gmail.com>

Looks good.

Reviewed-by: Alex Elder <elder@linaro.org>

> 
> Cheers,
>    Rui
> 
>> ---
>>   drivers/staging/greybus/light.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
>> index d62f97249aca..a5c2fe963866 100644
>> --- a/drivers/staging/greybus/light.c
>> +++ b/drivers/staging/greybus/light.c
>> @@ -95,15 +95,15 @@ static struct led_classdev *get_channel_cdev(struct gb_channel *channel)
>>   static struct gb_channel *get_channel_from_mode(struct gb_light *light,
>>   						u32 mode)
>>   {
>> -	struct gb_channel *channel = NULL;
>> +	struct gb_channel *channel;
>>   	int i;
>>   
>>   	for (i = 0; i < light->channels_count; i++) {
>>   		channel = &light->channels[i];
>> -		if (channel && channel->mode == mode)
>> -			break;
>> +		if (channel->mode == mode)
>> +			return channel;
>>   	}
>> -	return channel;
>> +	return NULL;
>>   }
>>   
>>   static int __gb_lights_flash_intensity_set(struct gb_channel *channel,
>> -- 
>> 2.43.0


      reply	other threads:[~2024-03-04 17:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04  7:04 [PATCH] staging: greybus: fix get_channel_from_mode() failure path Dan Carpenter
2024-03-04  9:17 ` Rui Miguel Silva
2024-03-04 17:49   ` Alex Elder [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1c77c0ef-c098-4962-909d-6bf53cdbde60@ieee.org \
    --to=elder@ieee.org \
    --cc=dan.carpenter@linaro.org \
    --cc=elder@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=greybus-dev@lists.linaro.org \
    --cc=johan@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=rmfrfs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox