Re: [RFC PATCH v2 07/22] ASoC: Add SOC USB APIs for adding an USB backend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2023/1/29 15:09, Greg KH wrote:
On Sun, Jan 29, 2023 at 02:54:43PM +0800, Zhou Furong wrote:


+void *snd_soc_usb_get_priv_data(struct device *usbdev)
+{
+	struct snd_soc_usb *ctx;
+
+	if (!usbdev)
+		return NULL;

How could usbdev ever be NULL?
The method is exported to public, valid check should be reasonable
as someone may call it by mistake

We do not protect the kernel from itself like this, no need to check
things that should never happen.  If the caller gets it wrong, their
code will break :)

thanks,

greg k-h

Thank you Greg!

This has been confused me for long time when I found Linux kernel don't check input even for public method.




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux