Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6628785rwl; Thu, 29 Dec 2022 17:01:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXuwIhIlQYOTNUAx9u0R7S7WyNaHkjM1gmeBbx42nZ7Zp70mfA5F0rgxUqw15pHQPr63GDxW X-Received: by 2002:a17:907:c28f:b0:7c1:eb:b2a7 with SMTP id tk15-20020a170907c28f00b007c100ebb2a7mr28627646ejc.13.1672362079468; Thu, 29 Dec 2022 17:01:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672362079; cv=none; d=google.com; s=arc-20160816; b=eRKEOHmH3qxJ5anR+L+5KJQLQLx8YamtGCrwYWL0D8WJXks3GiKT3+QHX4uQJVBZ8A Ptm6bkEkQBa9c4hNuzwg0SRkBofidf7Kh98aLHKoQGOnfXP8bVzD66Rollu5DU4EQ6gi FBwWRLL0W6Pl7/KEetMjLBZ8n3+Z7EGhT7FC0QQ2+avzw/u3Rfw7Op9PRU3xnS2oMYeH 09F4BOA5Xv0+KoZLjjwMh4Y/BuTDE1pDQeJy24obvMhHPMtCbctJcSNlU0yGVRnV42qm 2B8xQscwAzlzue69I8nllTrD+shYacioXlMEMDqqZM3Vm39t202hdi4x56UKiGs36Nsx NjTg== 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=CyWkmbfdqtlGY0rwiPi83ReuiFdfPg46opu9XRadU/A=; b=bvwp2IiEqHFfFKlkMmklxF2XYwn6Vmh4Cw+5H993N8QWH+tDCyLesrjTnNWWKAWzpJ lfJVvuFdEPDKWJDt2Faj7wslTV0C0mqI6GrlpsdhADpAiFzYfZtRHNn1ZjcW2XQZFGI8 mRGu+7XC5JudwMsQN7v63MuJsWxo82vt5v3qbBSlI7bqB4Hgd8zKvkksBqRsPiW1e9/Y AIkPrWTsN2ghAAfh0UZfq+eAKWLm6VPH29X+LIvzi6ZSr+RWovwMEmU+5USUxz6+eCSq UVbAeVb0zlC3gedpImMX5xSTpkyGv8T5+x+jPJETMBsJyqa/oHGnRBk3RRKQr8dKQ1wt E6rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=fx1KlIHv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn26-20020a1709070d1a00b0084c9dce9710si1105335ejc.978.2022.12.29.17.01.04; Thu, 29 Dec 2022 17:01:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=fx1KlIHv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234086AbiL3AOR (ORCPT + 63 others); Thu, 29 Dec 2022 19:14:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234095AbiL3AOP (ORCPT ); Thu, 29 Dec 2022 19:14:15 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C11313D55 for ; Thu, 29 Dec 2022 16:14:14 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id bg13-20020a05600c3c8d00b003d9712b29d2so11800098wmb.2 for ; Thu, 29 Dec 2022 16:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=CyWkmbfdqtlGY0rwiPi83ReuiFdfPg46opu9XRadU/A=; b=fx1KlIHvSJVrk+xOsmnVPA/zQYrSCik2VK7jM1MLNetCvtb0PMBJoxnN4K7WaEPHYm RmQtIPkhbP7znLcHv+Bx1P3+eLQferowU5K4tmabYE92hVnI6h+JreQYRA1dfMDxa9/V ynPmjtCetnrzNAult8OuvHXEyb4Mj61P+dH59JHTDhSt1M10Jto5VFxbVpBelOqy+zEC tmevg7STdGd7H8YP7rsvw1PPiXhm3LWy2CQ572VvDffZdUbs2/qwqpkO0N0m3/OjfbL4 OjZcH8UApH52C35bV8W2kMnL43QqL3DtIX05vNjvJpELrCRuX6Ba0c0GxfO+12HWk8i2 m6cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=CyWkmbfdqtlGY0rwiPi83ReuiFdfPg46opu9XRadU/A=; b=aGj64q5xySfNndsJOfiqtCjWL5WpvCfm6zQ2AWcTa7eIsYFV1a54I6N1Vs99yzf1by emUDB0L/AdgIk85wFvqK94B/8c1QoapVAVkdmof8lbbtmFi2h0Nz+ttJ0TTwdqywC60y aWXPgigCFrlLRj8lSnTc3aCbgpOmPKng/J+/fU7EEZ8IRTb229QMboD2DUziXED1rAF1 HnqTiplpISPbdugsCYfk9tWyeQHj6PJwD5nww5dhBx1gPQLQQ/cTenCcJ/5qrrfOvQV7 dASh8Bcwz+jt+4kAdDTSd0z03Ir0+eXE6LQc6r6Gg64SX+pzCH4iqk5r7siQuqa/ch2D YDZw== X-Gm-Message-State: AFqh2kqW66NAYVg1pPBnXVN2WuDUy8iqN+izWsiYWlMlpEC41oPqMj1t ibXvsJk61DCB1aUwCLHH2CTF0Q== X-Received: by 2002:a05:600c:a10:b0:3d2:2904:dfe9 with SMTP id z16-20020a05600c0a1000b003d22904dfe9mr24824442wmp.21.1672359252962; Thu, 29 Dec 2022 16:14:12 -0800 (PST) Received: from nicolas-Precision-3551.home ([2001:861:5180:dcc0:a1a7:f1c1:a2d2:514c]) by smtp.gmail.com with ESMTPSA id o8-20020a05600c4fc800b003d99a39b846sm5072994wmq.5.2022.12.29.16.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 16:14:12 -0800 (PST) From: Nicolas Frayer To: peter.ujfalusi@gmail.com, nm@ti.com, ssantosh@kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, grygorii.strashko@ti.com, khilman@baylibre.com, glaroque@baylibre.com, mkorpershoek@baylibre.com, nfrayer@baylibre.com Subject: [PATCH v2] soc: ti: k3-ringacc: Add try_module_get() to k3_dmaring_request_dual_ring() Date: Fri, 30 Dec 2022 01:14:04 +0100 Message-Id: <20221230001404.10902-1-nfrayer@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 When the k3 ring accelerator driver has been modified to add module build support, try_module_get() and module_put() have been added to update the module refcnt. One code path has not been updated and it has introduced an issue where the refcnt is decremented by module_put() in k3_ringacc_ring_free() without being incremented previously. Adding try_module_get() to k3_dmaring_request_dual_ring() ensures the refcnt is kept up to date. Fixes: c07f216a8b72 ("soc: ti: k3-ringacc: Allow the driver to be built as module") Signed-off-by: Nicolas Frayer Reviewed-by: Peter Ujfalusi --- v1->v2: Added the Fixes and Reviewed-by tags drivers/soc/ti/k3-ringacc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c index e01e4d815230a..8f131368a7586 100644 --- a/drivers/soc/ti/k3-ringacc.c +++ b/drivers/soc/ti/k3-ringacc.c @@ -406,6 +406,11 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id, mutex_lock(&ringacc->req_lock); + if (!try_module_get(ringacc->dev->driver->owner)) { + ret = -EINVAL; + goto err_module_get; + } + if (test_bit(fwd_id, ringacc->rings_inuse)) { ret = -EBUSY; goto error; @@ -421,6 +426,8 @@ static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id, return 0; error: + module_put(ringacc->dev->driver->owner); +err_module_get: mutex_unlock(&ringacc->req_lock); return ret; } -- 2.25.1