Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp725513pxb; Tue, 2 Feb 2021 16:48:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfDXXY0BLNwVr9ecF+kDn46Mhq2oAY7j45Hc9GF8gVb2h1wtqQiP4b/rQpX+sPG0bZpE2T X-Received: by 2002:a05:6402:5207:: with SMTP id s7mr601610edd.311.1612313325847; Tue, 02 Feb 2021 16:48:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313325; cv=none; d=google.com; s=arc-20160816; b=eGFx3aK0fB6ceLMIXFsl1o6yqHPPrTx716n2RX3oRWEkcW6QZo3RW0DD0ZQ/F8j0Et ydMI1tlCFf2ZW3TnGdB7XwenEB1yfJ2qQR/amTg11qtDB9SCz4XKER3a/2HTMOvXMnh5 404hjIlp2cI+nF9TLpnN0l28liCoMoW8S3GpwxhSdWSeT4+W8ZrNs+1fLv9A5x7AYIvj A7LFu8zlGaM3LHnfR8VHnsK3PercRf5WslQaNYFjlv/3uZggjlFUO4rvVLPYtzGBusbP ovtVLpCgC7btN4XU6x6EYkazUp28vXNfyZWvgyCFc8MSHy0mu9RBb54tlLVM7SOqvLht 0IeA== 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=t8WPOZIvF9AeW58CKEZ2X8MJBZJ1MlYi+mrQs6yIbsI=; b=ovmsVXXhUIeiMqJA5G/FYBdho25I6gbmFU4EMPrEYLf9QdqreVizgHon9S+37QY9Xy M0L5tX9tbEufPp4aN7XfZXzZjIrD4rVh59TPh4NNsVzN50ROGo3xa+6WSnVsnfRo8aL/ zp3Lu6tak2wihdHgSrAQAREuiM1Lv5tTWNmHqgtbrI+cmeAy6sf1MaL2qn2aOLjFxLoU 9C34zefLFF6l1aKrdQVnbk2ufY3ya0vNqtzlCAwdMxlGPw7nyjiCX3OISgmeizaARVT5 KwOe4zrXB+YRerVsrKULBwsegm5EfLCR2dYrWwPYNAl+166ANvGjM1FieT7B+i3+xHLH n+tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EBisOTM9; 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 v18si283844ejj.105.2021.02.02.16.48.21; Tue, 02 Feb 2021 16:48:45 -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=EBisOTM9; 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 S239871AbhBBTfK (ORCPT + 99 others); Tue, 2 Feb 2021 14:35:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:45298 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233364AbhBBN4g (ORCPT ); Tue, 2 Feb 2021 08:56:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 256FA64F6A; Tue, 2 Feb 2021 13:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273510; bh=9jI4xKYfiKIsaXaY4fKZ3vns/czDlGUzbtr3/Jyq51k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EBisOTM9AxBvh9E/3lh1KqatxEYv1TtGkYOldxdnjjsfVy6+ApNBnSWfxPTOkP4TZ HhRrZjijdkek0NPqUV7oDSohwHTvFDhzdu7PwaN6pIGSTvWYiDriry26CgJRdh8kem TwEXP1A2VqIRXPgvMXSa19rYQu0P2mZ/h3VP2b4Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pan Bian , Jakub Kicinski Subject: [PATCH 5.10 133/142] NFC: fix resource leak when target index is invalid Date: Tue, 2 Feb 2021 14:38:16 +0100 Message-Id: <20210202133003.182032473@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@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: Pan Bian commit 3a30537cee233fb7da302491b28c832247d89bbe upstream. Goto to the label put_dev instead of the label error to fix potential resource leak on path that the target index is invalid. Fixes: c4fbb6515a4d ("NFC: The core part should generate the target index") Signed-off-by: Pan Bian Link: https://lore.kernel.org/r/20210121152748.98409-1-bianpan2016@163.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/nfc/rawsock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/nfc/rawsock.c +++ b/net/nfc/rawsock.c @@ -105,7 +105,7 @@ static int rawsock_connect(struct socket if (addr->target_idx > dev->target_next_idx - 1 || addr->target_idx < dev->target_next_idx - dev->n_targets) { rc = -EINVAL; - goto error; + goto put_dev; } rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);