Skip to contentSkip to conversation

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

PATCH New Guenter Roeck 1 participant 1 message May 21, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
change since RFC:

	Dropped check for the result of container_of() result instead of
	checking if file->private_data is NULL.
 drivers/misc/xilinx_sdfec.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/misc/xilinx_sdfec.c +0 -3
index 23c8448a9c3b..d6e3c650bd11 100644
@@ -1013,9 +1013,6 @@ static __poll_t xsdfec_poll(struct file *file, poll_table *wait)
 
 	xsdfec = container_of(file->private_data, struct xsdfec_dev, miscdev);
 
-	if (!xsdfec)
-		return EPOLLNVAL | EPOLLHUP;
-
 	poll_wait(file, &xsdfec->waitq, wait);
 
 	/* XSDFEC ISR detected an error */
Signature · 1 line
2.25.1