Re: [PATCH v1] arcnet: Add NULL check in com20020pci_probe()

From: Andrew Lunn
Date: Tue Apr 01 2025 - 10:36:20 EST


On Tue, Apr 01, 2025 at 09:49:03PM +0800, Henry Martin wrote:
> devm_kasprintf() returns NULL when memory allocation fails. Currently,
> com20020pci_probe() does not check for this case, which results in a
> NULL pointer dereference.
>
> Add NULL check after devm_kasprintf() to prevent this issue.

It is more normal to add a test after each devm_kasprintf() rather
than one big one at the end. If the first fails, all the others are
going to fail as well, so you should not bother and just fail the
probe.

https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html

Andrew

---
pw-bot: cr