Message ID | 7946a26c6e53a4158f0f5bad5276d8654fd59415.1670673147.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1271243wrr; Sat, 10 Dec 2022 03:59:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf7b0DtfDpx+FNGbB3NKEMxbJZXstIYEFutntpjryVrFAcJWTgcwRupOn7vIslUhtUm8LAu6 X-Received: by 2002:a17:906:60c9:b0:7c1:b65:14c1 with SMTP id f9-20020a17090660c900b007c10b6514c1mr8206654ejk.10.1670673540877; Sat, 10 Dec 2022 03:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670673540; cv=none; d=google.com; s=arc-20160816; b=hYgVdbdB1D6+atNawso/O/i/QWRrgK5jHKnTElqm7EFOmKqI9SEOKmeBYuuBGfZwck HOBCx/+JSWMUxObe/Z7ZfaMIQpFL9wBhphFQ0xr2waLFg7wRsRLDtAkipoEvWriubPhm CZir4lm5lNPbVaHr1mxL9KQRk66hpproLdyBtLbAPUeSB9xO7dm52Xh0RhnIr/jqKOFD k9F0OdV5AR8LeJsCCT3RKkqHM2vJToVKi/AbOfAKXkqP/GeIdwb4ELkGKT0llC5oea0u FR+23Zk2cGycvY/ByLflmLVhfPkHjVAvZZpIDTt8wRhgee8tZ6ErbMy7g5ERKKVShK+J m0zA== 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; bh=7N5B5PGxAqBsyHP2Ca2Y76y0M04uX6VD5s8dc4DOZYg=; b=NbeIjwmEWABAvnflQykjpFQAS9g8HdpZmOEdCJC5miN6ZkbSRkL6PwmrkcOkWskYtD gtibFjwWb2FidLhpHh1smvSRBhOt2TCJWREFTM/MGpLQHhigkJUbH7xMkVju2/iCJ3w0 xD4PINp+U1yWqceFXLnsbLcuUXvMwQA4OAcWjU8qjajqcjrV3yr69K3MYjP0SAehvhBs acw2h5pUzP8Cznem67heZV5gniAw3Q91YOnjr6J4e7f/6cYCLrGlDdI3/q2tbGF+iUJs bVb/8m+z616AEITG6P1sIss7Tw/T/MTkvKAPCJdt8GfgbYPpTaG1QC1UhJotoJ7mEHGF k4tQ== ARC-Authentication-Results: i=1; mx.google.com; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kf27-20020a17090776db00b007ae286f26b1si1710552ejc.620.2022.12.10.03.58.30; Sat, 10 Dec 2022 03:59:00 -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; 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 S229733AbiLJLxK (ORCPT <rfc822;jz.zhangjin@gmail.com> + 99 others); Sat, 10 Dec 2022 06:53:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbiLJLxH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 10 Dec 2022 06:53:07 -0500 Received: from smtp.smtpout.orange.fr (smtp-20.smtpout.orange.fr [80.12.242.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD0E5FD3D for <linux-kernel@vger.kernel.org>; Sat, 10 Dec 2022 03:52:59 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id 3yPYpAeHxFUJ33yPYptfah; Sat, 10 Dec 2022 12:52:58 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 10 Dec 2022 12:52:58 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Max Filippov <jcmvbkbc@gmail.com>, Mark Brown <broonie@kernel.org>, Yang Yingliang <yangyingliang@huawei.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, linux-xtensa@linux-xtensa.org, linux-spi@vger.kernel.org Subject: [PATCH v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove() Date: Sat, 10 Dec 2022 12:52:53 +0100 Message-Id: <7946a26c6e53a4158f0f5bad5276d8654fd59415.1670673147.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751828178763432671?= X-GMAIL-MSGID: =?utf-8?q?1751828178763432671?= |
Series |
[v1] spi: xtensa-xtfpga: Fix a double put() in xtfpga_spi_remove()
|
|
Commit Message
Christophe JAILLET
Dec. 10, 2022, 11:52 a.m. UTC
'master' is allocated with devm_spi_alloc_master(), there is no need to
put it explicitly in the remove function.
Fixes: 478cc2fc3dd7 ("spi: xtensa-xtfpga: Switch to use devm_spi_alloc_master()")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/spi/spi-xtensa-xtfpga.c | 1 -
1 file changed, 1 deletion(-)
Comments
Hi Christophe, On Sat, Dec 10, 2022 at 3:52 AM Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > > 'master' is allocated with devm_spi_alloc_master(), there is no need to > put it explicitly in the remove function. > > Fixes: 478cc2fc3dd7 ("spi: xtensa-xtfpga: Switch to use devm_spi_alloc_master()") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > drivers/spi/spi-xtensa-xtfpga.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/drivers/spi/spi-xtensa-xtfpga.c b/drivers/spi/spi-xtensa-xtfpga.c > index 2fa7608f94cd..271ae98f441c 100644 > --- a/drivers/spi/spi-xtensa-xtfpga.c > +++ b/drivers/spi/spi-xtensa-xtfpga.c > @@ -123,7 +123,6 @@ static int xtfpga_spi_remove(struct platform_device *pdev) > struct xtfpga_spi *xspi = spi_master_get_devdata(master); > > spi_bitbang_stop(&xspi->bitbang); > - spi_master_put(master); This put is matching the get in the spi_bitbang_start. It was discussed here: https://lore.kernel.org/linux-spi/CAMo8BfJaD7pG_iutY8jordysjChyzhTpVSqpxXh3QoZsj2QmaQ@mail.gmail.com/
On Sat, Dec 10, 2022 at 06:48:02AM -0800, Max Filippov wrote: > Hi Christophe, > > On Sat, Dec 10, 2022 at 3:52 AM Christophe JAILLET > <christophe.jaillet@wanadoo.fr> wrote: > > 'master' is allocated with devm_spi_alloc_master(), there is no need to > > put it explicitly in the remove function. > > spi_bitbang_stop(&xspi->bitbang); > > - spi_master_put(master); > This put is matching the get in the spi_bitbang_start. > It was discussed here: > https://lore.kernel.org/linux-spi/CAMo8BfJaD7pG_iutY8jordysjChyzhTpVSqpxXh3QoZsj2QmaQ@mail.gmail.com/ Probably worth a comment though since it is a bit of a gotcha. Ideally we'd improve this in the bitbang code but that's harder.
On Tue, Dec 13, 2022 at 09:30:32AM +0800, Yang Yingliang wrote: > On 2022/12/12 23:36, Mark Brown wrote: > > On Sat, Dec 10, 2022 at 06:48:02AM -0800, Max Filippov wrote: > > Probably worth a comment though since it is a bit of a gotcha. Ideally > > we'd improve this in the bitbang code but that's harder. > Ideally, spi_bitbang_stop() should undo spi_bitbang_start(). shall we move > spi_master_put() in spi_bitbang_stop() instead of > calling it separately in drivers? Ideally like I say, there's issues with devm IIRC which make it more complicated than just adding a put() there.
diff --git a/drivers/spi/spi-xtensa-xtfpga.c b/drivers/spi/spi-xtensa-xtfpga.c index 2fa7608f94cd..271ae98f441c 100644 --- a/drivers/spi/spi-xtensa-xtfpga.c +++ b/drivers/spi/spi-xtensa-xtfpga.c @@ -123,7 +123,6 @@ static int xtfpga_spi_remove(struct platform_device *pdev) struct xtfpga_spi *xspi = spi_master_get_devdata(master); spi_bitbang_stop(&xspi->bitbang); - spi_master_put(master); return 0; }