From 067391fa38b2264eb51fe7286ee4d8e5dc13bc87 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 30 Jul 2022 17:27:20 +0200 Subject: [PATCH] 4.14-stable patches added patches: scsi-ufs-host-hold-reference-returned-by-of_parse_phandle.patch --- ...ference-returned-by-of_parse_phandle.patch | 56 +++++++++++++++++++ queue-4.14/series | 1 + 2 files changed, 57 insertions(+) create mode 100644 queue-4.14/scsi-ufs-host-hold-reference-returned-by-of_parse_phandle.patch diff --git a/queue-4.14/scsi-ufs-host-hold-reference-returned-by-of_parse_phandle.patch b/queue-4.14/scsi-ufs-host-hold-reference-returned-by-of_parse_phandle.patch new file mode 100644 index 00000000000..42e5a203310 --- /dev/null +++ b/queue-4.14/scsi-ufs-host-hold-reference-returned-by-of_parse_phandle.patch @@ -0,0 +1,56 @@ +From a3435afba87dc6cd83f5595e7607f3c40f93ef01 Mon Sep 17 00:00:00 2001 +From: Liang He +Date: Tue, 19 Jul 2022 15:15:29 +0800 +Subject: scsi: ufs: host: Hold reference returned by of_parse_phandle() + +From: Liang He + +commit a3435afba87dc6cd83f5595e7607f3c40f93ef01 upstream. + +In ufshcd_populate_vreg(), we should hold the reference returned by +of_parse_phandle() and then use it to call of_node_put() for refcount +balance. + +Link: https://lore.kernel.org/r/20220719071529.1081166-1-windhl@126.com +Fixes: aa4976130934 ("ufs: Add regulator enable support") +Reviewed-by: Bart Van Assche +Signed-off-by: Liang He +Signed-off-by: Martin K. Petersen +Signed-off-by: Greg Kroah-Hartman +--- + drivers/scsi/ufs/ufshcd-pltfrm.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +--- a/drivers/scsi/ufs/ufshcd-pltfrm.c ++++ b/drivers/scsi/ufs/ufshcd-pltfrm.c +@@ -124,9 +124,20 @@ out: + return ret; + } + ++static bool phandle_exists(const struct device_node *np, ++ const char *phandle_name, int index) ++{ ++ struct device_node *parse_np = of_parse_phandle(np, phandle_name, index); ++ ++ if (parse_np) ++ of_node_put(parse_np); ++ ++ return parse_np != NULL; ++} ++ + #define MAX_PROP_SIZE 32 + static int ufshcd_populate_vreg(struct device *dev, const char *name, +- struct ufs_vreg **out_vreg) ++ struct ufs_vreg **out_vreg) + { + int ret = 0; + char prop_name[MAX_PROP_SIZE]; +@@ -139,7 +150,7 @@ static int ufshcd_populate_vreg(struct d + } + + snprintf(prop_name, MAX_PROP_SIZE, "%s-supply", name); +- if (!of_parse_phandle(np, prop_name, 0)) { ++ if (!phandle_exists(np, prop_name, 0)) { + dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n", + __func__, prop_name); + goto out; diff --git a/queue-4.14/series b/queue-4.14/series index d6efa48bc98..d482c0fe152 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -1,3 +1,4 @@ bluetooth-l2cap-fix-use-after-free-caused-by-l2cap_chan_put.patch ntfs-fix-use-after-free-in-ntfs_ucsncmp.patch s390-archrandom-prevent-cpacf-trng-invocations-in-interrupt-context.patch +scsi-ufs-host-hold-reference-returned-by-of_parse_phandle.patch -- 2.47.3