]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Jul 2022 07:16:43 +0000 (09:16 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Jul 2022 07:16:43 +0000 (09:16 +0200)
added patches:
dmaengine-at_xdma-handle-errors-of-at_xdmac_alloc_desc-correctly.patch
dmaengine-ti-add-missing-put_device-in-ti_dra7_xbar_route_allocate.patch
dmaengine-ti-fix-refcount-leak-in-ti_dra7_xbar_route_allocate.patch
ida-don-t-use-bug_on-for-debugging.patch

queue-4.9/dmaengine-at_xdma-handle-errors-of-at_xdmac_alloc_desc-correctly.patch [new file with mode: 0644]
queue-4.9/dmaengine-ti-add-missing-put_device-in-ti_dra7_xbar_route_allocate.patch [new file with mode: 0644]
queue-4.9/dmaengine-ti-fix-refcount-leak-in-ti_dra7_xbar_route_allocate.patch [new file with mode: 0644]
queue-4.9/i2c-cadence-unregister-the-clk-notifier-in-error-pat.patch
queue-4.9/ida-don-t-use-bug_on-for-debugging.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/dmaengine-at_xdma-handle-errors-of-at_xdmac_alloc_desc-correctly.patch b/queue-4.9/dmaengine-at_xdma-handle-errors-of-at_xdmac_alloc_desc-correctly.patch
new file mode 100644 (file)
index 0000000..94bd339
--- /dev/null
@@ -0,0 +1,36 @@
+From 3770d92bd5237d686e49da7b2fb86f53ee6ed259 Mon Sep 17 00:00:00 2001
+From: Michael Walle <michael@walle.cc>
+Date: Thu, 26 May 2022 15:51:11 +0200
+Subject: dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly
+
+From: Michael Walle <michael@walle.cc>
+
+commit 3770d92bd5237d686e49da7b2fb86f53ee6ed259 upstream.
+
+It seems that it is valid to have less than the requested number of
+descriptors. But what is not valid and leads to subsequent errors is to
+have zero descriptors. In that case, abort the probing.
+
+Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
+Signed-off-by: Michael Walle <michael@walle.cc>
+Link: https://lore.kernel.org/r/20220526135111.1470926-1-michael@walle.cc
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/dma/at_xdmac.c |    5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/drivers/dma/at_xdmac.c
++++ b/drivers/dma/at_xdmac.c
+@@ -1806,6 +1806,11 @@ static int at_xdmac_alloc_chan_resources
+       for (i = 0; i < init_nr_desc_per_channel; i++) {
+               desc = at_xdmac_alloc_desc(chan, GFP_ATOMIC);
+               if (!desc) {
++                      if (i == 0) {
++                              dev_warn(chan2dev(chan),
++                                       "can't allocate any descriptors\n");
++                              return -EIO;
++                      }
+                       dev_warn(chan2dev(chan),
+                               "only %d descriptors have been allocated\n", i);
+                       break;
diff --git a/queue-4.9/dmaengine-ti-add-missing-put_device-in-ti_dra7_xbar_route_allocate.patch b/queue-4.9/dmaengine-ti-add-missing-put_device-in-ti_dra7_xbar_route_allocate.patch
new file mode 100644 (file)
index 0000000..2685b6d
--- /dev/null
@@ -0,0 +1,55 @@
+From 615a4bfc426e11dba05c2cf343f9ac752fb381d2 Mon Sep 17 00:00:00 2001
+From: Miaoqian Lin <linmq006@gmail.com>
+Date: Sun, 5 Jun 2022 08:27:22 +0400
+Subject: dmaengine: ti: Add missing put_device in ti_dra7_xbar_route_allocate
+
+From: Miaoqian Lin <linmq006@gmail.com>
+
+commit 615a4bfc426e11dba05c2cf343f9ac752fb381d2 upstream.
+
+of_find_device_by_node() takes reference, we should use put_device()
+to release it when not need anymore.
+
+Fixes: a074ae38f859 ("dmaengine: Add driver for TI DMA crossbar on DRA7x")
+Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
+Acked-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
+Link: https://lore.kernel.org/r/20220605042723.17668-1-linmq006@gmail.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/dma/ti-dma-crossbar.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/dma/ti-dma-crossbar.c
++++ b/drivers/dma/ti-dma-crossbar.c
+@@ -251,6 +251,7 @@ static void *ti_dra7_xbar_route_allocate
+       if (dma_spec->args[0] >= xbar->xbar_requests) {
+               dev_err(&pdev->dev, "Invalid XBAR request number: %d\n",
+                       dma_spec->args[0]);
++              put_device(&pdev->dev);
+               return ERR_PTR(-EINVAL);
+       }
+@@ -258,12 +259,14 @@ static void *ti_dra7_xbar_route_allocate
+       dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0);
+       if (!dma_spec->np) {
+               dev_err(&pdev->dev, "Can't get DMA master\n");
++              put_device(&pdev->dev);
+               return ERR_PTR(-EINVAL);
+       }
+       map = kzalloc(sizeof(*map), GFP_KERNEL);
+       if (!map) {
+               of_node_put(dma_spec->np);
++              put_device(&pdev->dev);
+               return ERR_PTR(-ENOMEM);
+       }
+@@ -275,6 +278,7 @@ static void *ti_dra7_xbar_route_allocate
+               dev_err(&pdev->dev, "Run out of free DMA requests\n");
+               kfree(map);
+               of_node_put(dma_spec->np);
++              put_device(&pdev->dev);
+               return ERR_PTR(-ENOMEM);
+       }
+       set_bit(map->xbar_out, xbar->dma_inuse);
diff --git a/queue-4.9/dmaengine-ti-fix-refcount-leak-in-ti_dra7_xbar_route_allocate.patch b/queue-4.9/dmaengine-ti-fix-refcount-leak-in-ti_dra7_xbar_route_allocate.patch
new file mode 100644 (file)
index 0000000..15e3308
--- /dev/null
@@ -0,0 +1,33 @@
+From c132fe78ad7b4ce8b5d49a501a15c29d08eeb23a Mon Sep 17 00:00:00 2001
+From: Miaoqian Lin <linmq006@gmail.com>
+Date: Sun, 5 Jun 2022 08:27:23 +0400
+Subject: dmaengine: ti: Fix refcount leak in ti_dra7_xbar_route_allocate
+
+From: Miaoqian Lin <linmq006@gmail.com>
+
+commit c132fe78ad7b4ce8b5d49a501a15c29d08eeb23a upstream.
+
+of_parse_phandle() returns a node pointer with refcount
+incremented, we should use of_node_put() on it when not needed anymore.
+
+Add missing of_node_put() in to fix this.
+
+Fixes: ec9bfa1e1a79 ("dmaengine: ti-dma-crossbar: dra7: Use bitops instead of idr")
+Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
+Link: https://lore.kernel.org/r/20220605042723.17668-2-linmq006@gmail.com
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/dma/ti-dma-crossbar.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/drivers/dma/ti-dma-crossbar.c
++++ b/drivers/dma/ti-dma-crossbar.c
+@@ -274,6 +274,7 @@ static void *ti_dra7_xbar_route_allocate
+               mutex_unlock(&xbar->mutex);
+               dev_err(&pdev->dev, "Run out of free DMA requests\n");
+               kfree(map);
++              of_node_put(dma_spec->np);
+               return ERR_PTR(-ENOMEM);
+       }
+       set_bit(map->xbar_out, xbar->dma_inuse);
index 888ad49a4488b220770d05a2f3e45adb94a70d0c..b30085d7610720743c966e01f3b283035f5b138b 100644 (file)
@@ -17,14 +17,12 @@ Reviewed-by: Michal Simek <michal.simek@amd.com>
 Signed-off-by: Wolfram Sang <wsa@kernel.org>
 Signed-off-by: Sasha Levin <sashal@kernel.org>
 ---
- drivers/i2c/busses/i2c-cadence.c | 1 +
+ drivers/i2c/busses/i2c-cadence.c |    1 +
  1 file changed, 1 insertion(+)
 
-diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
-index a29ac9bae6d5..9ab056bb834d 100644
 --- a/drivers/i2c/busses/i2c-cadence.c
 +++ b/drivers/i2c/busses/i2c-cadence.c
-@@ -992,6 +992,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
+@@ -992,6 +992,7 @@ static int cdns_i2c_probe(struct platfor
        return 0;
  
  err_clk_dis:
@@ -32,6 +30,3 @@ index a29ac9bae6d5..9ab056bb834d 100644
        clk_disable_unprepare(id->clk);
        pm_runtime_set_suspended(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
--- 
-2.35.1
-
diff --git a/queue-4.9/ida-don-t-use-bug_on-for-debugging.patch b/queue-4.9/ida-don-t-use-bug_on-for-debugging.patch
new file mode 100644 (file)
index 0000000..514e223
--- /dev/null
@@ -0,0 +1,59 @@
+From fc82bbf4dede758007763867d0282353c06d1121 Mon Sep 17 00:00:00 2001
+From: Linus Torvalds <torvalds@linux-foundation.org>
+Date: Sun, 10 Jul 2022 13:55:49 -0700
+Subject: ida: don't use BUG_ON() for debugging
+
+From: Linus Torvalds <torvalds@linux-foundation.org>
+
+commit fc82bbf4dede758007763867d0282353c06d1121 upstream.
+
+This is another old BUG_ON() that just shouldn't exist (see also commit
+a382f8fee42c: "signal handling: don't use BUG_ON() for debugging").
+
+In fact, as Matthew Wilcox points out, this condition shouldn't really
+even result in a warning, since a negative id allocation result is just
+a normal allocation failure:
+
+  "I wonder if we should even warn here -- sure, the caller is trying to
+   free something that wasn't allocated, but we don't warn for
+   kfree(NULL)"
+
+and goes on to point out how that current error check is only causing
+people to unnecessarily do their own index range checking before freeing
+it.
+
+This was noted by Itay Iellin, because the bluetooth HCI socket cookie
+code does *not* do that range checking, and ends up just freeing the
+error case too, triggering the BUG_ON().
+
+The HCI code requires CAP_NET_RAW, and seems to just result in an ugly
+splat, but there really is no reason to BUG_ON() here, and we have
+generally striven for allocation models where it's always ok to just do
+
+    free(alloc());
+
+even if the allocation were to fail for some random reason (usually
+obviously that "random" reason being some resource limit).
+
+Fixes: 88eca0207cf1 ("ida: simplified functions for id allocation")
+Reported-by: Itay Iellin <ieitayie@gmail.com>
+Suggested-by: Matthew Wilcox <willy@infradead.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ lib/idr.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/lib/idr.c
++++ b/lib/idr.c
+@@ -1124,7 +1124,9 @@ void ida_simple_remove(struct ida *ida,
+ {
+       unsigned long flags;
+-      BUG_ON((int)id < 0);
++      if ((int)id < 0)
++              return;
++
+       spin_lock_irqsave(&simple_ida_lock, flags);
+       ida_remove(ida, id);
+       spin_unlock_irqrestore(&simple_ida_lock, flags);
index 841adabd1c3ae6b8ba8cc194a31613a0b2543b38..2d961030f3e2b73b33edd6d6b689882ce3cb1720 100644 (file)
@@ -8,3 +8,7 @@ video-of_display_timing.h-include-errno.h.patch
 xfs-remove-incorrect-assert-in-xfs_rename.patch
 pinctrl-sunxi-a83t-fix-nand-function-name-for-some-p.patch
 i2c-cadence-unregister-the-clk-notifier-in-error-pat.patch
+ida-don-t-use-bug_on-for-debugging.patch
+dmaengine-at_xdma-handle-errors-of-at_xdmac_alloc_desc-correctly.patch
+dmaengine-ti-fix-refcount-leak-in-ti_dra7_xbar_route_allocate.patch
+dmaengine-ti-add-missing-put_device-in-ti_dra7_xbar_route_allocate.patch