Skip to contentSkip to conversation

cxl/mbox: Replace NULL check with IS_ERR() after vmemdup_user()

PATCH In review [email protected] 2 participants 2 messages Apr 7, 2022 – Apr 12, 2022 CXL

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 cxl/mbox: Replace NULL check with IS_ERR() after vmemdup_user()

From: Alison Schofield <[email protected]>

vmemdup_user() returns an ERR_PTR() on failure. Use IS_ERR() to check the return value.

Fixes be0d0ce77aa3 ("cxl/mbox: Move build of user mailbox cmd to a helper funct

ions")

---
 drivers/cxl/core/mbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/mbox.c +1 -1
index 8a8388599a85..2449878d4b4b 100644
@@ -263,7 +263,7 @@ static int cxl_mbox_cmd_ctor(struct cxl_mbox_cmd *mbox,
 	if (in_size) {
 		mbox->payload_in = vmemdup_user(u64_to_user_ptr(in_payload),
 						in_size);
-		if (!mbox->payload_in)
+		if (IS_ERR(mbox->payload_in))
 			return PTR_ERR(mbox->payload_in);
 
 		if (!cxl_payload_from_user_allowed(opcode, mbox->payload_in)) {

base-commit: 7dc1d11d7abae52aada5340fb98885f0ddbb7c37

Signature · 1 line
2.31.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Alison Schofield

From: Alison Schofield <[email protected]>

vmemdup_user() returns an ERR_PTR() on failure. Use IS_ERR() to check the return value.

Fixes be0d0ce77aa3 ("cxl/mbox: Move build of user mailbox cmd to a helper funct

ions")

Quoted 22 lines
---
 drivers/cxl/core/mbox.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cxl/core/mbox.c +1 -1
index 8a8388599a85..2449878d4b4b 100644
@@ -263,7 +263,7 @@ static int cxl_mbox_cmd_ctor(struct cxl_mbox_cmd *mbox,
 	if (in_size) {
 		mbox->payload_in = vmemdup_user(u64_to_user_ptr(in_payload),
 						in_size);
-		if (!mbox->payload_in)
+		if (IS_ERR(mbox->payload_in))
 			return PTR_ERR(mbox->payload_in);
 
 		if (!cxl_payload_from_user_allowed(opcode, mbox->payload_in)) {

base-commit: 7dc1d11d7abae52aada5340fb98885f0ddbb7c37

Signature · 1 line
2.31.1