mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: quic_zijuhu <quic_zijuhu@quicinc.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: <rafael@kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] devres: Initialize a uninitialized struct member
Date: Tue, 18 Jun 2024 19:29:59 +0800	[thread overview]
Message-ID: <d029d754-aeb7-493a-8e48-6acaa53fee1e@quicinc.com> (raw)
In-Reply-To: <2024061726-payment-editor-7431@gregkh>

On 6/18/2024 2:14 AM, Greg KH wrote:
> On Mon, Jun 17, 2024 at 09:09:25PM +0800, Zijun Hu wrote:
>> Use memset() after kmalloc() a struct devres_group to initialize
>> potential uninitialized members such as @color within kernel API
>> devres_open_group() as alloc_dr() does.
>>
>> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
>> ---
>>  drivers/base/devres.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/base/devres.c b/drivers/base/devres.c
>> index 3df0025d12aa..ba3e4603cd77 100644
>> --- a/drivers/base/devres.c
>> +++ b/drivers/base/devres.c
>> @@ -558,6 +558,10 @@ void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
>>  	if (unlikely(!grp))
>>  		return NULL;
>>  
>> +	/* No need to clear memory twice */
>> +	if (!(gfp & __GFP_ZERO))
>> +		memset(grp, 0, sizeof(*grp));
> 
> Is this an actual bugfix (i.e. do we have uninitialized fields today?)
> 
no, maybe take it as code optimization instead of bugfix.
yes, field grp->color is NOT initialized.
> If so, what commit does this fix?
> 
> thanks,
> 
> greg k-h


  reply	other threads:[~2024-06-18 11:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-17 13:09 Zijun Hu
2024-06-17 18:14 ` Greg KH
2024-06-18 11:29   ` quic_zijuhu [this message]
2024-06-27 13:47     ` [PATCH] devres: Simple code optimization Zijun Hu
2024-06-27 13:54       ` Greg KH
2024-06-27 14:29         ` quic_zijuhu
2024-06-27 14:35           ` Greg KH
2024-06-27 15:13             ` quic_zijuhu

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=d029d754-aeb7-493a-8e48-6acaa53fee1e@quicinc.com \
    --to=quic_zijuhu@quicinc.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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

all inboxes | Powered by JetHome®