Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2929750rwb; Mon, 15 Aug 2022 14:15:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR65nSAkxq5jgaDqQI8TKHdXFbFPlPZZ+ycSETCgxFZIF0vSfroqj1Xcq5xhIq3rpW1B3W6j X-Received: by 2002:a05:6402:378f:b0:43a:d3f5:79f2 with SMTP id et15-20020a056402378f00b0043ad3f579f2mr16316165edb.338.1660598133357; Mon, 15 Aug 2022 14:15:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598133; cv=none; d=google.com; s=arc-20160816; b=liQh/XVWdhJv27vNxRzNf5yFj1sLjv3D7YE2MX7Xtxf2tB0gbgEVfWgVP8VTkvCjrU rmvgj6OXw7OaQDfIoISM7I8hWlZxztqxL7d13xSz2KhPY5zY1ybVCd1Gpwbd8xP9/t9f al3LQF1fS6BRGOvCCVmirQoEysjiK00v6xHE2znW4TuZdXmqkY2/o1FoUGxtn7uMwhjs eZOWYiRmRXtoam4MKYwFs802OruzdpUSwbiq3l2IxFPce2xbd64IvOnW7T4O4SsPd2U/ Z9T2qRU+7FUDzb7T3cbMEbEfpSqxDbTraba1X0hObX5lu+3B2KJAc95aVJ+5xQOc3qyU Nonw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VLVRzsBUQRoq3SWm4HKeI8W90HP2PQxg/IV/SmDhCl8=; b=E+RlDzsj4Ed+VkDiUbM6/gBxxf8bQqEr8X1+EgfZbcrCrUgLDrm5I0iELdAG+5Dfzu Ke48SEusQOnJmP92x81bK0Fl/Mt+ITRO+xZdhmHT7HXKYCcXKKIFyzWKxd382ojXrQlT HlD9CxFCgaNrwlKE7SsEoWzxdrvovI0L1Y1z8qdvv9fLEjW6f+MO42Hf3gOPhmljo6OY JEEcC6OncFPxsFEG/ftaOH+RmHIeeWcwqKEhXKIElyGTYazAJYpz7+Dp0YVScUVOJ3oS b/TH+SlLpPixnbOpluEXnjWvsg6agCdCFD8L9zlcOP7x2dyhSs73VGLwQXVP3Ww/9CtC bhRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="A1XOta/x"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv13-20020a17090760cd00b007382da624cbsi5848465ejc.539.2022.08.15.14.15.05; Mon, 15 Aug 2022 14:15:33 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="A1XOta/x"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348148AbiHOUcL (ORCPT + 99 others); Mon, 15 Aug 2022 16:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347754AbiHOU0f (ORCPT ); Mon, 15 Aug 2022 16:26:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C329DFB4; Mon, 15 Aug 2022 12:03:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 01704612A5; Mon, 15 Aug 2022 19:03:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF945C433C1; Mon, 15 Aug 2022 19:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590219; bh=trG8oyJvYdJGnFL4oAnns9pnq+hwSnbarSZgSlzOSAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A1XOta/xmxjPe8h6fNm88wGdhbzhjyoF/aWql8YfX/lBIJgUx90XHerl2Ekaa1xmU zXA5X0Gk4VG1WJv17fiI3Sec2spxxscmSK+TzwjKM+UF5fZAadmQxi4QQd+JmNKWQU beqvr99cTetQe2lyPzx2K7WR6E1AJj6acuchBMsM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Mark Brown , Sasha Levin Subject: [PATCH 5.18 0190/1095] spi: spi-altera-dfl: Fix an error handling path Date: Mon, 15 Aug 2022 19:53:09 +0200 Message-Id: <20220815180437.492814629@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Christophe JAILLET [ Upstream commit 8e3ca32f46994e74b7f43c57731150b2aedb2630 ] The spi_alloc_master() call is not undone in all error handling paths. Moreover, there is no .remove function to release the allocated memory. In order to fix both this issues, switch to devm_spi_alloc_master(). This allows further simplification of the probe. Fixes: ba2fc167e944 ("spi: altera: Add DFL bus driver for Altera API Controller") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/0607bb59f4073f86abe5c585d35245aef0b045c6.1653805901.git.christophe.jaillet@wanadoo.fr Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-altera-dfl.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-altera-dfl.c b/drivers/spi/spi-altera-dfl.c index ca40923258af..596e181ae136 100644 --- a/drivers/spi/spi-altera-dfl.c +++ b/drivers/spi/spi-altera-dfl.c @@ -128,9 +128,9 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) struct spi_master *master; struct altera_spi *hw; void __iomem *base; - int err = -ENODEV; + int err; - master = spi_alloc_master(dev, sizeof(struct altera_spi)); + master = devm_spi_alloc_master(dev, sizeof(struct altera_spi)); if (!master) return -ENOMEM; @@ -159,10 +159,9 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) altera_spi_init_master(master); err = devm_spi_register_master(dev, master); - if (err) { - dev_err(dev, "%s failed to register spi master %d\n", __func__, err); - goto exit; - } + if (err) + return dev_err_probe(dev, err, "%s failed to register spi master\n", + __func__); if (dfl_dev->revision == FME_FEATURE_REV_MAX10_SPI_N5010) strscpy(board_info.modalias, "m10-n5010", SPI_NAME_SIZE); @@ -179,9 +178,6 @@ static int dfl_spi_altera_probe(struct dfl_device *dfl_dev) } return 0; -exit: - spi_master_put(master); - return err; } static const struct dfl_device_id dfl_spi_altera_ids[] = { -- 2.35.1