linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
To: Helen Koike <helen.koike@collabora.com>,
	Dafna Hirschfeld <dafna.hirschfeld@collabora.com>,
	linux-media@vger.kernel.org
Cc: ezequiel@collabora.com, andre.almeida@collabora.com,
	skhan@linuxfoundation.org, hverkuil@xs4all.nl,
	kernel@collabora.com, dafna3@gmail.com
Subject: Re: [PATCH 1/3] media: vimc: initialize vim entity pointers to NULL
Date: Tue, 1 Oct 2019 19:25:32 +0200	[thread overview]
Message-ID: <f5120bc3-9fe8-e8ec-af2c-c24331031885@collabora.com> (raw)
In-Reply-To: <d2d5bf0d-1a21-1363-9450-ff1783f1790e@collabora.com>

Hi Dafna, hi Helen,

W dniu 01.10.2019 o 19:19, Helen Koike pisze:
> Hi Dafna,
> 
> On 10/1/19 1:50 PM, Dafna Hirschfeld wrote:
>> since NULL value for vimc entity pointer indicates
>> that entity creation failed and this is tested, the
>> pointers should be initialized to NULL.
> 
> Nice catch :)
> 
>>
>> Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com>
>> ---
>>   drivers/media/platform/vimc/vimc-core.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
>> index 6e3e5c91ae39..32a79e578b78 100644
>> --- a/drivers/media/platform/vimc/vimc-core.c
>> +++ b/drivers/media/platform/vimc/vimc-core.c
>> @@ -160,19 +160,17 @@ static int vimc_create_links(struct vimc_device *vimc)
>>   static int vimc_add_subdevs(struct vimc_device *vimc)
>>   {
>>   	unsigned int i;
>> -	struct vimc_ent_device *ved;
>>   
>>   	for (i = 0; i < vimc->pipe_cfg->num_ents; i++) {
>>   		dev_dbg(&vimc->pdev.dev, "new entity for %s\n",
>>   			vimc->pipe_cfg->ents[i].name);
>> -		ved = vimc->pipe_cfg->ents[i].add(vimc,
>> +		vimc->ent_devs[i] = vimc->pipe_cfg->ents[i].add(vimc,
>>   					vimc->pipe_cfg->ents[i].name);
>> -		if (!ved) {
>> +		if (!vimc->ent_devs[i]) {
>>   			dev_err(&vimc->pdev.dev, "add new entity for %s\n",
>>   				vimc->pipe_cfg->ents[i].name);
>>   			return -EINVAL;
>>   		}
>> -		vimc->ent_devs[i] = ved;
>>   	}
>>   	return 0;
>>   }
> 
> I believe just the kcalloc bellow should fix the issue.
> But if you want to do this cleanup anyway, I would suggest sending a separate patch for it.
> 
>> @@ -199,7 +197,7 @@ static int vimc_register_devices(struct vimc_device *vimc)
>>   	}
>>   
>>   	/* allocate ent_devs */
>> -	vimc->ent_devs = kmalloc_array(vimc->pipe_cfg->num_ents,
>> +	vimc->ent_devs = kcalloc(vimc->pipe_cfg->num_ents,
>>   				       sizeof(*vimc->ent_devs),
>>   				       GFP_KERNEL);
> 
> Could you fix the alignment of the params here?

Isn't the above change (kmalloc_array() to kcalloc()) alone enough
to ensure the promise from the patch title is fulfilled?

In other words, why remove the "ved" local variable in vimc_add_subdevs()?

Andrzej

  reply	other threads:[~2019-10-01 17:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-01 16:50 [PATCH 0/3] media: vimc: bug fixes related to memory management Dafna Hirschfeld
2019-10-01 16:50 ` [PATCH 1/3] media: vimc: initialize vim entity pointers to NULL Dafna Hirschfeld
2019-10-01 17:19   ` Helen Koike
2019-10-01 17:25     ` Andrzej Pietrasiewicz [this message]
2019-10-01 17:35       ` Helen Koike
2019-10-01 17:38         ` Andrzej Pietrasiewicz
2019-10-01 16:50 ` [PATCH 2/3] media: vimc: sensor: register subdevice only after initialization Dafna Hirschfeld
2019-10-01 17:22   ` Helen Koike
2019-10-01 16:50 ` [PATCH 3/3] media: vimc: move media_entity_cleanup to release callbacks Dafna Hirschfeld
2019-10-01 17:33   ` Helen Koike

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=f5120bc3-9fe8-e8ec-af2c-c24331031885@collabora.com \
    --to=andrzej.p@collabora.com \
    --cc=andre.almeida@collabora.com \
    --cc=dafna.hirschfeld@collabora.com \
    --cc=dafna3@gmail.com \
    --cc=ezequiel@collabora.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-media@vger.kernel.org \
    --cc=skhan@linuxfoundation.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;
as well as URLs for NNTP newsgroup(s).