Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4445857pxb; Mon, 21 Feb 2022 21:52:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzT7L/KEe9C2bkWAlR7a1aTNEqF1R3jpLVmGMrwIP4o/E+m5BprehCg6E0iugCqQQsQUtUc X-Received: by 2002:a63:2b48:0:b0:36c:54fb:43c3 with SMTP id r69-20020a632b48000000b0036c54fb43c3mr18235778pgr.611.1645509162735; Mon, 21 Feb 2022 21:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645509162; cv=none; d=google.com; s=arc-20160816; b=d+Dhxj6iXKrQ1Knt8rpsIlgoHkGfXbrdvYjFkFgGd5xowTzKsKYvCO/zBvwYCkki06 twyOhSfOdUWUVB22GJ8kuJgKjsyIUlPFPmyKE9ou1qpFPG4onbVarZJ1whi1z1l11REo l5OI6aLPxC1C6wpkUhcVgZ8V7SxkVztpIMFLNB9VErQBJQvdkPq0OcuTcS8tDdEFOdbO rcVn3Pg3mDF15GL6xmACe/3ULIpecrfVf7lL7yo8tHY+nxjYwD/uh1wdK8srJxN56j2G kaCpCvCSddP/K1trXVhUGY0gIkE+6WxnoP5vaAR7FDHnwjbwXAmTAmjPqL9HwPSvMVps xT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=W4e0Or5RWevHd+mvZ+oPOZ9BD4lXm7waqKeZmhpiEe8=; b=uzBsqgckdwP3Oa6FGLGUdMCffn7hqqUCMBy9R1kzBAyg/AIqQHUG8WIjOFq6Anr1t+ lhB6B/N5MgI7jWcP7BF3SIMWA4aE+fpbguLvJm+ie7wkMFwEfq7mzmV7vJH0LQk2lwKW rlqhQOqdyJC4wz6y3OIFwdkciV0yRzLfxlj1slPgS0FG5ycOkNl1wDg3aUKeSSYEE9jv 25JHoekcWccvOdp8B3K8bQYq4LPVc6gufEmgbYjcZTS0qPhOihG7n9yuuzpkNI+A0L9K hbBiUqf/BxDkYVrAWHH4U03cKTqvv2eCH9tXmgKVHPvvXxntN5zFRjEGZ7/29oWUD7kj m7XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HvRx0IuZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h7si32179677plo.539.2022.02.21.21.52.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:52:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=HvRx0IuZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 42477137770; Mon, 21 Feb 2022 21:15:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238827AbiBVB7s (ORCPT + 99 others); Mon, 21 Feb 2022 20:59:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:49622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbiBVB7s (ORCPT ); Mon, 21 Feb 2022 20:59:48 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB4401EECA; Mon, 21 Feb 2022 17:59:23 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id u20so21870034lff.2; Mon, 21 Feb 2022 17:59:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=W4e0Or5RWevHd+mvZ+oPOZ9BD4lXm7waqKeZmhpiEe8=; b=HvRx0IuZd0XT6yuS0ZZUz/89gM8iXDEjmGhF2pXnT5CWZAj9B//bSwT0Q/H1FYjUyf gyAS28/L7MKeypEo3xteO2B4W82J7OOAlKuQjEqh9qtfAq95N65BUIV/nUTuIXakhN58 MimOcmF077XqKlrqrGdYULn7rtOux4KBqKyAdvFm1ddyIzJByVDpmz8s3fu7w5SondJh Y3zEOM6grOEr5WZ3mQ33dOXWFlRJCKQH+6g+NtjryqyUAYHWypDUBr1/6z1NPxTrDiE0 ucaczRo8RgBVIp2+9JEZRFgHbP1Psmq5X50Jc6E+kUROob6Ri0Y3rn2nloQwwYVYmF5a 0zCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=W4e0Or5RWevHd+mvZ+oPOZ9BD4lXm7waqKeZmhpiEe8=; b=ZtzK9VUoe7YL2W6M7nLrApkpJZ6lRdvtn/O+cLlQryp1A4Q+/wLtbdB1hftNhH9yRy g68q7GILrlVsVXXux/PC3dzH3yp8c9+5H67iNRGIOThP1ajs4N+aO5YTq5A6sH5OT24X I7WuMPpxv3rRU/tXkR5xsb/JtA6EDviCwOfXOxFX/R4K4P02w4RtoknCgpl6C8orEZDs kikajNI0/NTxwViQREytDPHUNuMu9s0X1mom9bnE7lwrNESXBdl51VQvhspy01f9zoXz 7JU/Gxb+ymg99Xl02RtbnLebYGY6CSahoNfbFgJdxO++7HWo7+cEzhaCgNfHgvMYqirj G2Gw== X-Gm-Message-State: AOAM533U/D265S0sSIN3hTNF2VBwRyEdM1YS3nROrrDi1Zkqp+Xf9f62 QwJDnKesIoj7VVSlgqmqow5+M/Wj/HT0YZqX X-Received: by 2002:a05:6512:31cf:b0:443:7eb6:3440 with SMTP id j15-20020a05651231cf00b004437eb63440mr15283210lfe.367.1645495161995; Mon, 21 Feb 2022 17:59:21 -0800 (PST) Received: from TebraArch.. ([81.198.32.225]) by smtp.gmail.com with ESMTPSA id 10sm1255051lfq.201.2022.02.21.17.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 17:59:21 -0800 (PST) From: =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= To: linux-kernel@vger.kernel.org Cc: Vinod Koul , dmaengine@vger.kernel.org, =?UTF-8?q?D=C4=81vis=20Mos=C4=81ns?= Subject: [PATCH] dmaengine: fix locking for dma_channel_rebalance Date: Tue, 22 Feb 2022 03:58:49 +0200 Message-Id: <20220222015849.14727-1-davispuh@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org dma_channel_rebalance comment says: > Must be called under dma_list_mutex We have few places where it wasn't done and could cause crashes. So invoke it only when it's under mutex. --- drivers/dma/dmaengine.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 2cfa8458b51be..5198bdf7ee804 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -1098,7 +1098,10 @@ int dma_async_device_channel_register(struct dma_device *device, if (rc < 0) return rc; + mutex_lock(&dma_list_mutex); dma_channel_rebalance(); + mutex_unlock(&dma_list_mutex); + return 0; } EXPORT_SYMBOL_GPL(dma_async_device_channel_register); @@ -1124,7 +1127,9 @@ void dma_async_device_channel_unregister(struct dma_device *device, struct dma_chan *chan) { __dma_async_device_channel_unregister(device, chan); + mutex_lock(&dma_list_mutex); dma_channel_rebalance(); + mutex_unlock(&dma_list_mutex); } EXPORT_SYMBOL_GPL(dma_async_device_channel_unregister); -- 2.35.1