Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

misc: xilinx-sdfec: Drop unnecessary NULL check after container_of

container_of() only returns NULL if the passed pointer is NULL _and_ if
the embedded element is the first element of the structure. Even if that
is the case, testing against it is misleading and possibly dangerous
because the position of the embedded element may change. In this case,
the check is unnecessary since it is known that file->private_data is
never NULL for an open file, and container_of() will therefore also
never be NULL. Drop the check.

Acked-by: Dragan Cvetic <dragan.cvetic@xilinx.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210521200457.2112041-1-linux@roeck-us.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Guenter Roeck and committed by
Greg Kroah-Hartman
78429edf b63866ef

-3
-3
drivers/misc/xilinx_sdfec.c
··· 1013 1013 1014 1014 xsdfec = container_of(file->private_data, struct xsdfec_dev, miscdev); 1015 1015 1016 - if (!xsdfec) 1017 - return EPOLLNVAL | EPOLLHUP; 1018 - 1019 1016 poll_wait(file, &xsdfec->waitq, wait); 1020 1017 1021 1018 /* XSDFEC ISR detected an error */