From 670e79efe6c787f363160e9bd8f0a145b216d701 Mon Sep 17 00:00:00 2001 From: jixj Date: Fri, 22 Feb 2019 15:54:44 +0800 Subject: [PATCH] usb/gadget/f_fs: fix invalid ffs to cause ramdump QC patch("usb: gadget: f_fs: Fix NULL pointer issues in ffs driver") fix multiple mounted issue, it will return "ERR_PTR(-EBUSY)" in ffs_data_new(), but ffs driver only check ffs if is a NULL point, the next code using ffs still cause ramdump. origin-CR: (CR) Change-Id: Ib2d21b2854163883f07475ef97e1e09a1742c617 Reviewed-on: https://gerrit.mot.com/1313122 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Huosheng Liao Reviewed-by: Yuecai Liu Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1338906 Reviewed-on: https://gerrit.mot.com/1449057 Reviewed-on: https://gerrit.mot.com/1751135 Reviewed-by: Xiaojun Ji Reviewed-on: https://gerrit.mot.com/1785338 --- drivers/usb/gadget/function/f_fs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 55b94532c43a..b399dacbd839 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1768,6 +1768,7 @@ static int ffs_fs_get_tree(struct fs_context *fc) return invalf(fc, "No source specified"); ffs = ffs_data_new(fc->source); + if (IS_ERR_OR_NULL(ffs)) { if (!ffs) return -ENOMEM; @@ -1775,6 +1776,9 @@ static int ffs_fs_get_tree(struct fs_context *fc) return PTR_ERR(ffs); } + if (IS_ERR(ffs)) + return PTR_ERR(ffs); + ffs->file_perms = ctx->perms; ffs->no_disconnect = ctx->no_disconnect;