Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9096942pxu; Mon, 28 Dec 2020 06:33:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2OhFaFalZzdn2/OrnSi3KoFuVOTzKE4Wf/yFD+m7eYfVsYjs/deCqKZbgcRT+sYeThDGT X-Received: by 2002:a17:906:3111:: with SMTP id 17mr12125192ejx.152.1609166031241; Mon, 28 Dec 2020 06:33:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166031; cv=none; d=google.com; s=arc-20160816; b=og6Ds87WdZWP8QuEAx8HBa2s+ACLOI5f5kfK2lWJujOxJvXyiQqi7xcr9N0QXd6T3c ZhxzPN/KFf5uEKOtXKuy9PeMhr/wC85TgWonuCU3Q1u6Co77Q9G1HCZ0Q0XYqqzGc7Dp gT78aoqtthHwtLKP/0SX4Xkp2Nhf4uHGY6XKjlDe4Evx7VYQZfNldhShrwUqQv593fYu 0sai/DhYoXsvjs41wMkkRiuHobqnEVUzF5dYwIFJEzDvXCYwpWr/abIPEwDlUA0jHtt9 I/lRyuagv3bz15qmOSFMnvxpoBf5vP34K+vzWvh/61ec4DY3d1mqU0f8w1ftuND+3dKE 8a8Q== 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=3knpsAu+R2Z1UiTsza+ZgkY7mk9AYqlmgAbz0h31rWk=; b=j6koMYN6gWxY6KlY+HRsKjRC6RG7j2HZuiV/H6Jdmx01+ecAr5XyS7oH3KfcpCJdBL 0W7RDIImAFPCryJ3oXqRJZDaMI37C3Ban0YqTPZ5eDBrS+Vby/buBetXV4LI2NC4duUB te+MfOcu61qUP4EfGyjQQ9Z2wmJQVXpt6r60f0NcX31infbquQlcB+/RU//kKA8v5cr9 LXg0rDrulff/pPVZrZm4QyGa3CkFX3LX6ieQsvymm26mfmW6xucfET9z7QFiiI3xSFZu lYJNDnb/+oxlMHAV+HdgeGUxJzR4q6dxe0bnjtUGnk92aDVIhvX55z3sJkXACdTETswP 3DRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OyCx2D5W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h18si19488196ejg.486.2020.12.28.06.33.28; Mon, 28 Dec 2020 06:33:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OyCx2D5W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2503573AbgL1OaI (ORCPT + 99 others); Mon, 28 Dec 2020 09:30:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:37236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503517AbgL1OaA (ORCPT ); Mon, 28 Dec 2020 09:30:00 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 567692063A; Mon, 28 Dec 2020 14:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165784; bh=4QNrSvkhcb45febz3gyZQuCw5TBarU7vQw7vc9eJhyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OyCx2D5WrpeRMe4gsHbI6h12aJTnqcvojko217CQ9eM9IZfKZYBxEgm6bTZRVHf/Q kFKhD6WYl+WXDvI3SZ1aR3Kh92HpkRi9trrfFawatnyOfB5CMJoN1gBWnjxishYAT3 +W28n9OTv+BIJdzkyRF5tJZkzHlW/jGBbiIz8yc0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lukas Wunner , Phil Reid , Mark Brown Subject: [PATCH 5.10 654/717] spi: sc18is602: Dont leak SPI master in probe error path Date: Mon, 28 Dec 2020 13:50:52 +0100 Message-Id: <20201228125052.279810463@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lukas Wunner commit 5b8c88462d83331dacb48aeaec8388117fef82e0 upstream. If the call to devm_gpiod_get_optional() fails on probe of the NXP SC18IS602/603 SPI driver, the spi_master struct is erroneously not freed. Fix by switching over to the new devm_spi_alloc_master() helper. Fixes: f99008013e19 ("spi: sc18is602: Add reset control via gpio pin.") Signed-off-by: Lukas Wunner Cc: # v4.9+: 5e844cc37a5c: spi: Introduce device-managed SPI controller allocation Cc: # v4.9+ Cc: Phil Reid Link: https://lore.kernel.org/r/d5f715527b894b91d530fe11a86f51b3184a4e1a.1607286887.git.lukas@wunner.de Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-sc18is602.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) --- a/drivers/spi/spi-sc18is602.c +++ b/drivers/spi/spi-sc18is602.c @@ -238,13 +238,12 @@ static int sc18is602_probe(struct i2c_cl struct sc18is602_platform_data *pdata = dev_get_platdata(dev); struct sc18is602 *hw; struct spi_master *master; - int error; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) return -EINVAL; - master = spi_alloc_master(dev, sizeof(struct sc18is602)); + master = devm_spi_alloc_master(dev, sizeof(struct sc18is602)); if (!master) return -ENOMEM; @@ -298,15 +297,7 @@ static int sc18is602_probe(struct i2c_cl master->min_speed_hz = hw->freq / 128; master->max_speed_hz = hw->freq / 4; - error = devm_spi_register_master(dev, master); - if (error) - goto error_reg; - - return 0; - -error_reg: - spi_master_put(master); - return error; + return devm_spi_register_master(dev, master); } static const struct i2c_device_id sc18is602_id[] = {