From 24752ccf9ce58150a682f78c69932bce82d9ff60 Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Mon, 13 Feb 2023 01:33:46 -0500 Subject: [PATCH] Fixes for 5.4 Signed-off-by: Sasha Levin --- ...-fix-confusing-types-in-return-value.patch | 38 ++++++++++ ...store-the-pins-that-used-to-be-in-di.patch | 69 +++++++++++++++++++ ...ingle-fix-potential-null-dereference.patch | 41 +++++++++++ queue-5.4/series | 3 + 4 files changed, 151 insertions(+) create mode 100644 queue-5.4/pinctrl-aspeed-fix-confusing-types-in-return-value.patch create mode 100644 queue-5.4/pinctrl-intel-restore-the-pins-that-used-to-be-in-di.patch create mode 100644 queue-5.4/pinctrl-single-fix-potential-null-dereference.patch diff --git a/queue-5.4/pinctrl-aspeed-fix-confusing-types-in-return-value.patch b/queue-5.4/pinctrl-aspeed-fix-confusing-types-in-return-value.patch new file mode 100644 index 00000000000..99c6257ed27 --- /dev/null +++ b/queue-5.4/pinctrl-aspeed-fix-confusing-types-in-return-value.patch @@ -0,0 +1,38 @@ +From 18157423b88aada890784aa89dbc7f1b271bbf6c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 20 Jan 2023 09:48:56 +1030 +Subject: pinctrl: aspeed: Fix confusing types in return value + +From: Joel Stanley + +[ Upstream commit 287a344a11f1ebd31055cf9b22c88d7005f108d7 ] + +The function signature is int, but we return a bool. Instead return a +negative errno as the kerneldoc suggests. + +Fixes: 4d3d0e4272d8 ("pinctrl: Add core support for Aspeed SoCs") +Signed-off-by: Joel Stanley +Reviewed-by: Andrew Jeffery +Link: https://lore.kernel.org/r/20230119231856.52014-1-joel@jms.id.au +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/aspeed/pinctrl-aspeed.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed.c b/drivers/pinctrl/aspeed/pinctrl-aspeed.c +index 22aca6d182c0c..2c1e799b029e7 100644 +--- a/drivers/pinctrl/aspeed/pinctrl-aspeed.c ++++ b/drivers/pinctrl/aspeed/pinctrl-aspeed.c +@@ -115,7 +115,7 @@ static int aspeed_disable_sig(struct aspeed_pinmux_data *ctx, + int ret = 0; + + if (!exprs) +- return true; ++ return -EINVAL; + + while (*exprs && !ret) { + ret = aspeed_sig_expr_disable(ctx, *exprs); +-- +2.39.0 + diff --git a/queue-5.4/pinctrl-intel-restore-the-pins-that-used-to-be-in-di.patch b/queue-5.4/pinctrl-intel-restore-the-pins-that-used-to-be-in-di.patch new file mode 100644 index 00000000000..83d03f02f79 --- /dev/null +++ b/queue-5.4/pinctrl-intel-restore-the-pins-that-used-to-be-in-di.patch @@ -0,0 +1,69 @@ +From a43aa1d11f0610d6042ecfd3b1d94e557519b14d Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 6 Feb 2023 16:15:59 +0200 +Subject: pinctrl: intel: Restore the pins that used to be in Direct IRQ mode + +From: Andy Shevchenko + +[ Upstream commit a8520be3ffef3d25b53bf171a7ebe17ee0154175 ] + +If the firmware mangled the register contents too much, +check the saved value for the Direct IRQ mode. If it +matches, we will restore the pin state. + +Reported-by: Jim Minter +Fixes: 6989ea4881c8 ("pinctrl: intel: Save and restore pins in "direct IRQ" mode") +Tested-by: Jim Minter +Signed-off-by: Andy Shevchenko +Acked-by: Mika Westerberg +Link: https://lore.kernel.org/r/20230206141558.20916-1-andriy.shevchenko@linux.intel.com +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/intel/pinctrl-intel.c | 16 +++++++++++++--- + 1 file changed, 13 insertions(+), 3 deletions(-) + +diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c +index e0cb76f7e5407..32c6326337f73 100644 +--- a/drivers/pinctrl/intel/pinctrl-intel.c ++++ b/drivers/pinctrl/intel/pinctrl-intel.c +@@ -1510,6 +1510,12 @@ int intel_pinctrl_probe_by_uid(struct platform_device *pdev) + EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_uid); + + #ifdef CONFIG_PM_SLEEP ++static bool __intel_gpio_is_direct_irq(u32 value) ++{ ++ return (value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) && ++ (__intel_gpio_get_gpio_mode(value) == PADCFG0_PMODE_GPIO); ++} ++ + static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int pin) + { + const struct pin_desc *pd = pin_desc_get(pctrl->pctldev, pin); +@@ -1543,8 +1549,7 @@ static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int + * See https://bugzilla.kernel.org/show_bug.cgi?id=214749. + */ + value = readl(intel_get_padcfg(pctrl, pin, PADCFG0)); +- if ((value & PADCFG0_GPIROUTIOXAPIC) && (value & PADCFG0_GPIOTXDIS) && +- (__intel_gpio_get_gpio_mode(value) == PADCFG0_PMODE_GPIO)) ++ if (__intel_gpio_is_direct_irq(value)) + return true; + + return false; +@@ -1656,7 +1661,12 @@ int intel_pinctrl_resume_noirq(struct device *dev) + void __iomem *padcfg; + u32 val; + +- if (!intel_pinctrl_should_save(pctrl, desc->number)) ++ if (!(intel_pinctrl_should_save(pctrl, desc->number) || ++ /* ++ * If the firmware mangled the register contents too much, ++ * check the saved value for the Direct IRQ mode. ++ */ ++ __intel_gpio_is_direct_irq(pads[i].padcfg0))) + continue; + + padcfg = intel_get_padcfg(pctrl, desc->number, PADCFG0); +-- +2.39.0 + diff --git a/queue-5.4/pinctrl-single-fix-potential-null-dereference.patch b/queue-5.4/pinctrl-single-fix-potential-null-dereference.patch new file mode 100644 index 00000000000..4627bebf0c8 --- /dev/null +++ b/queue-5.4/pinctrl-single-fix-potential-null-dereference.patch @@ -0,0 +1,41 @@ +From 764b4caada001c713c3a42a6f0e816b214b6b44a Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 18 Nov 2022 13:43:32 +0300 +Subject: pinctrl: single: fix potential NULL dereference + +From: Maxim Korotkov + +[ Upstream commit d2d73e6d4822140445ad4a7b1c6091e0f5fe703b ] + +Added checking of pointer "function" in pcs_set_mux(). +pinmux_generic_get_function() can return NULL and the pointer +"function" was dereferenced without checking against NULL. + +Found by Linux Verification Center (linuxtesting.org) with SVACE. + +Fixes: 571aec4df5b7 ("pinctrl: single: Use generic pinmux helpers for managing functions") +Signed-off-by: Maxim Korotkov +Reviewed-by: Tony Lindgren +Link: https://lore.kernel.org/r/20221118104332.943-1-korotkov.maxim.s@gmail.com +Signed-off-by: Linus Walleij +Signed-off-by: Sasha Levin +--- + drivers/pinctrl/pinctrl-single.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c +index 20c89023d312e..ce5be6f0b7aac 100644 +--- a/drivers/pinctrl/pinctrl-single.c ++++ b/drivers/pinctrl/pinctrl-single.c +@@ -345,6 +345,8 @@ static int pcs_set_mux(struct pinctrl_dev *pctldev, unsigned fselector, + if (!pcs->fmask) + return 0; + function = pinmux_generic_get_function(pctldev, fselector); ++ if (!function) ++ return -EINVAL; + func = function->data; + if (!func) + return -EINVAL; +-- +2.39.0 + diff --git a/queue-5.4/series b/queue-5.4/series index 5aabe98da1d..df62223336b 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -74,3 +74,6 @@ ice-do-not-use-wq_mem_reclaim-flag-for-workqueue.patch rds-rds_rm_zerocopy_callback-use-list_first_entry.patch selftests-forwarding-lib-quote-the-sysctl-values.patch alsa-pci-lx6464es-fix-a-debug-loop.patch +pinctrl-aspeed-fix-confusing-types-in-return-value.patch +pinctrl-single-fix-potential-null-dereference.patch +pinctrl-intel-restore-the-pins-that-used-to-be-in-di.patch -- 2.47.2