LKML Archive mirror
 help / color / mirror / Atom feed
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Bingbu Cao <bingbu.cao@intel.com>,
	Tianshu Qiu <tian.shu.qiu@intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] media: intel/ipu6: Fix an error handling path in isys_probe()
Date: Mon, 20 May 2024 12:53:46 +0200	[thread overview]
Message-ID: <68377fae-d6be-4658-ad4a-c9df8c3548d7@wanadoo.fr> (raw)
In-Reply-To: <ZksqOEXE0vCSPzYY@kekkonen.localdomain>

Le 20/05/2024 à 12:47, Sakari Ailus a écrit :
> Hi Christophe,
> 
> Thanks for the patch.
> 
> On Mon, May 20, 2024 at 12:32:30PM +0200, Christophe JAILLET wrote:
>> If an error occurs after a successful alloc_fw_msg_bufs() call, some
>> resources should be released as already done in the remove function.
>>
>> Fixes: f50c4ca0a820 ("media: intel/ipu6: add the main input system driver")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> Compile tested only
>> ---
>>   drivers/media/pci/intel/ipu6/ipu6-isys.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys.c b/drivers/media/pci/intel/ipu6/ipu6-isys.c
>> index 5992138c7290..d9e1e1a135b9 100644
>> --- a/drivers/media/pci/intel/ipu6/ipu6-isys.c
>> +++ b/drivers/media/pci/intel/ipu6/ipu6-isys.c
>> @@ -1062,6 +1062,7 @@ static int isys_probe(struct auxiliary_device *auxdev,
>>   	const struct ipu6_isys_internal_csi2_pdata *csi2_pdata;
>>   	struct ipu6_bus_device *adev = auxdev_to_adev(auxdev);
>>   	struct ipu6_device *isp = adev->isp;
>> +	struct isys_fw_msgs *fwmsg, *safe;
>>   	const struct firmware *fw;
>>   	struct ipu6_isys *isys;
>>   	unsigned int i;
>> @@ -1140,12 +1141,17 @@ static int isys_probe(struct auxiliary_device *auxdev,
>>   
>>   	ret = isys_register_devices(isys);
>>   	if (ret)
>> -		goto out_remove_pkg_dir_shared_buffer;
>> +		goto free_fw_msg_bufs;
>>   
>>   	ipu6_mmu_hw_cleanup(adev->mmu);
>>   
>>   	return 0;
>>   
>> +free_fw_msg_bufs:
>> +	list_for_each_entry_safe(fwmsg, safe, &isys->framebuflist, head)
>> +		dma_free_attrs(&auxdev->dev, sizeof(struct isys_fw_msgs),
>> +			       fwmsg, fwmsg->dma_addr, 0);
> 
> This is also done in isys_remove(). How about moving these into a new
> function that releases memory from both lists?

I agree. I thought about that too but decided to propose a simple 
solution first.

> 
> There's no harm in traversing framebuflist_fw as well, it's empty at this
> point.

Yes, that's my understanding.
That's why I only copied one list_for_each_entry_safe().


I'll send a v2 with the list_for_each_entry_safe() in a new function.
It will be much cleaner.

CJ

> 
>> +
>>   out_remove_pkg_dir_shared_buffer:
>>   	if (!isp->secure_mode)
>>   		ipu6_cpd_free_pkg_dir(adev);
> 


      reply	other threads:[~2024-05-20 10:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-20 10:32 [PATCH] media: intel/ipu6: Fix an error handling path in isys_probe() Christophe JAILLET
2024-05-20 10:47 ` Sakari Ailus
2024-05-20 10:53   ` Christophe JAILLET [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=68377fae-d6be-4658-ad4a-c9df8c3548d7@wanadoo.fr \
    --to=christophe.jaillet@wanadoo.fr \
    --cc=bingbu.cao@intel.com \
    --cc=hdegoede@redhat.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@intel.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).