Linux-Media Archive mirror
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-media@vger.kernel.org, Bingbu Cao <bingbu.cao@intel.com>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: Re: [PATCH 1/1] media: ipu6: Fix vmalloc memory allocation
Date: Thu, 2 May 2024 11:03:35 +0100	[thread overview]
Message-ID: <20240502110335.7b3495ab@sal.lan> (raw)
In-Reply-To: <20240502061525.1004018-1-sakari.ailus@linux.intel.com>

Em Thu,  2 May 2024 09:15:25 +0300
Sakari Ailus <sakari.ailus@linux.intel.com> escreveu:

> The driver was calling vmalloc() to allocate memory, something which isn't
> available except when particular Kconfig settings are enabled.
> 
> Use kvmalloc() instead.
> 
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Fixes: 25fedc021985 ("media: intel/ipu6: add Intel IPU6 PCI device driver")
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> Hi Stephen,
> 
> Thanks for reporting this. I'm a bit surprised this wasn't catched
> earlier. But it seems vmalloc() is defined in some configuration.
> 
> - Sakari
> 
>  drivers/media/pci/intel/ipu6/ipu6.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/pci/intel/ipu6/ipu6.c b/drivers/media/pci/intel/ipu6/ipu6.c
> index 4b1f69d14d71..082b1d6196be 100644
> --- a/drivers/media/pci/intel/ipu6/ipu6.c
> +++ b/drivers/media/pci/intel/ipu6/ipu6.c
> @@ -526,7 +526,7 @@ static int request_cpd_fw(const struct firmware **firmware_p, const char *name,
>  	}
>  
>  	dst->size = fw->size;
> -	dst->data = vmalloc(fw->size);
> +	dst->data = kvmalloc(fw->size, GFP_KERNEL);

Where are you freeing it? If I understood the code right, you're storing
dst at isp->cpd_fw, but I can't see any code freeing it nor cpw_fw->data
at device removal.

Also, there is a logic there at the same function checking for vmalloc:

	if (is_vmalloc_addr(fw->data)) {
		*firmware_p = fw;
		return 0;
	}

As now the memory may not be inside vmalloc space, shouldn't this
be changed as well?

Regards,
Mauro

>  	if (!dst->data) {
>  		kfree(dst);
>  		ret = -ENOMEM;

  reply	other threads:[~2024-05-02 10:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240501102236.3b2585d1@canb.auug.org.au>
2024-05-02  6:15 ` [PATCH 1/1] media: ipu6: Fix vmalloc memory allocation Sakari Ailus
2024-05-02 10:03   ` Mauro Carvalho Chehab [this message]
2024-05-02 15:49 ` [PATCH 1/1] media: intel/ipu6: Don't re-allocate memory for firmware Sakari Ailus

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=20240502110335.7b3495ab@sal.lan \
    --to=mchehab@kernel.org \
    --cc=bingbu.cao@intel.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sfr@canb.auug.org.au \
    /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).