* probe fail, what with devm_kzalloc, kcalloc data?
@ 2020-04-03 12:47 Tomek The Messenger
2020-04-03 14:27 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Tomek The Messenger @ 2020-04-03 12:47 UTC (permalink / raw)
To: kernelnewbies
[-- Attachment #1.1: Type: text/plain, Size: 663 bytes --]
Hi
What happens with devm_kzalloc and devm_kcalloc data when probe function
returns not 0?
Is this memory automatically deallocated?
Example below:
static struct my_data* my_static_pointer;
static int somedriver_do_probe(struct platform_device *pdev)
{
int ret;
struct device *dev = &pdev->dev;
dev_info(dev, "probe\n");
my_static_pointer= devm_kzalloc(dev, sizeof(struct my_data), GFP_KERNEL);
if (! my_static_pointer )
return -ENOMEM;
....
let's say memory was also allocated with devm_kcalloc somewhere in the
meantime
...
//do sthm:
if (ret != 0 )
return -EINVAL; //let's assume there we returned from probe, what with
allocated so far memory???
...
}
[-- Attachment #1.2: Type: text/html, Size: 902 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: probe fail, what with devm_kzalloc, kcalloc data?
2020-04-03 12:47 probe fail, what with devm_kzalloc, kcalloc data? Tomek The Messenger
@ 2020-04-03 14:27 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2020-04-03 14:27 UTC (permalink / raw)
To: Tomek The Messenger; +Cc: kernelnewbies
On Fri, Apr 03, 2020 at 02:47:50PM +0200, Tomek The Messenger wrote:
> Hi
> What happens with devm_kzalloc and devm_kcalloc data when probe function
> returns not 0?
> Is this memory automatically deallocated?
Yes.
Try it and see :)
greg k-h
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-03 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 12:47 probe fail, what with devm_kzalloc, kcalloc data? Tomek The Messenger
2020-04-03 14:27 ` Greg KH
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).