[PATCH] firmware: edd: fix a NULL pointer dereference
From: Kangjie Lu
Date: Sat Mar 23 2019 - 18:10:30 EST
As other functions in this module do, edev should be checked to
ensure that it is not NULL.
The fix inserts such as check to avoid potential NULL pointer
dereference.
Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
---
drivers/firmware/edd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c
index 1b82c89a49df..7ebfaca53721 100644
--- a/drivers/firmware/edd.c
+++ b/drivers/firmware/edd.c
@@ -279,6 +279,8 @@ static ssize_t
edd_show_mbr_signature(struct edd_device *edev, char *buf)
{
char *p = buf;
+ if (!edev)
+ return -EINVAL;
p += scnprintf(p, left, "0x%08x\n", edev->mbr_signature);
return (p - buf);
}
--
2.17.1