[PATCH net-next v3 01/10] net: wwan: tmi: Add PCIe core

Jakub Kicinski kuba at kernel.org
Thu Feb 16 10:10:34 PST 2023


On Thu, 16 Feb 2023 12:50:44 +0000 Yanchao Yang (杨彦超) wrote:
> > > +	pci_clear_master(pdev);
> > > +	mtk_mhccif_exit(mdev);
> > > +	mtk_pci_free_irq(mdev);
> > > +	mtk_pci_bar_exit(mdev);
> > > +	pci_disable_device(pdev);
> > > +	pci_load_and_free_saved_state(pdev, &priv->saved_state);
> > > +	devm_kfree(dev, priv);
> > > +	devm_kfree(dev, mdev);  
> > 
> > Why are you using devm_ if you call kfree explicitly anyway?
> > You can save some memory by using kfree() directly.  
> devm_kzalloc(), devm_ioremap_resource(), devm_request_irq(),
> devm_gpio_request(), devm_clk_get()…..
> They will be freed automatically
> when corresponding device is freed, so you don’t have to free them
> explicitly. This also make probe error easier to handle. Is it ok?

Yes.



More information about the Linux-mediatek mailing list