Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp995664yba; Thu, 4 Apr 2019 02:01:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9jGnqzP6Yc7Xm/21MlbywwQkf6QFyfXDMPPnDrL5LwirSvH/KYva2YVs9UJT5HMKtcWtw X-Received: by 2002:a17:902:b597:: with SMTP id a23mr5000368pls.284.1554368516832; Thu, 04 Apr 2019 02:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554368516; cv=none; d=google.com; s=arc-20160816; b=V+Fk5Auqpxs4QZ/DurnIIcfHjPjl2WwYl5i8eUuVaFBoQfpeajmcJQzR44mt8IzJRz R1ctTAlI4RlfNXppEwvhFQP1XNIq7IOXMD0OAvq3DyTarPNspPe+ppFSNFsKnMRuznlo 9PsZUY61NKTR0n/6tW2L/fomRPaYZtDVNcLwWaCpjpcE/T/Q7ByPUQnER3pv0+dvlmT3 PsnHHGzmX23yMS0OkiIqlixnNO114izPqcwmL2OmzVHzI8OgwjCHwa8g0HsWT7eojVEF JR7s7BkLlWjtF6huqWo4vZ2kiwunY4zsuzmMlejUcgDx60DQRNMxxUPlHKCGdW4eINUL x/1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WBZZ11/fpp0eiXJ3Gy4TL+2s8WL1mRPsFwZXijTTH3M=; b=uR8nsqwxhHV3Y3yU53ZWD4nbMYSinvm7mOHmCoQdbrzuejvhlqcrm5w8wvNtvsVarF iJ+Fk42+3HQz0Lt+LmFteYa9r/yp4hPDjN9rrBUX8mRaKeF5EordmBa70zuSLNlvx6RT vCT5+jNFhOyPiIqA+FR2V1aWx4IsDCHZ26vN3yBkXE8++pU43nbpEeIeCP5+q9WT1B26 d69kEpO0AA9WutORBfZ0kAm2nQe+ByXt/x0+md22u9iix+MhQ9j5Af0XZTSSWOoo5eE+ JLpUHfBSG8cMBIbxsP12ir3whPAU7ue+FNbRjqx5JcZhOSnDp1fAuER5A+k9JC5p/a17 Wupg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2ShqQo0Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j4si2874292pfc.101.2019.04.04.02.01.41; Thu, 04 Apr 2019 02:01:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2ShqQo0Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731368AbfDDJBH (ORCPT + 99 others); Thu, 4 Apr 2019 05:01:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:38056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730446AbfDDJBF (ORCPT ); Thu, 4 Apr 2019 05:01:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF01F21741; Thu, 4 Apr 2019 09:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368464; bh=jNTb3dUjH/H2hvsA5PLRckeSce98Sa3onMsch0ZvF9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2ShqQo0YJQ2UkNwYDBKzEmu5uic/ucVk9H5rJlbwe9UnrRlks31z2qcDyODO1OfnS OHlGQ3SEDAjLmXl2rCiMyYvvW6nz8KrqkC2UJiJFm9nsdznT7Oselh/LBs2GCE2ekC NytE9IYYagDVxKZHvPH/A4yTDRwu2F2HtlICCU8g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Felix Fietkau , Lorenzo Bianconi , Kalle Valo , "David S. Miller" , Matthias Brugger , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Sasha Levin Subject: [PATCH 4.19 049/187] mt76: fix a leaked reference by adding a missing of_node_put Date: Thu, 4 Apr 2019 10:46:26 +0200 Message-Id: <20190404084605.380921548@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 34e022d8b780a03902d82fb3997ba7c7b1f40c81 ] The call to of_find_node_by_phandle returns a node pointer with refcount incremented thus it must be explicitly decremented after the last usage. Detected by coccinelle with the following warnings: ./drivers/net/wireless/mediatek/mt76/eeprom.c:58:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:61:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:67:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:70:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. ./drivers/net/wireless/mediatek/mt76/eeprom.c:72:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 48, but without a corresponding object release within this function. Signed-off-by: Wen Yang Cc: Felix Fietkau Cc: Lorenzo Bianconi Cc: Kalle Valo Cc: "David S. Miller" Cc: Matthias Brugger Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mediatek@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/mediatek/mt76/eeprom.c | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/eeprom.c b/drivers/net/wireless/mediatek/mt76/eeprom.c index 530e5593765c..a1529920d877 100644 --- a/drivers/net/wireless/mediatek/mt76/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/eeprom.c @@ -54,22 +54,30 @@ mt76_get_of_eeprom(struct mt76_dev *dev, int len) part = np->name; mtd = get_mtd_device_nm(part); - if (IS_ERR(mtd)) - return PTR_ERR(mtd); + if (IS_ERR(mtd)) { + ret = PTR_ERR(mtd); + goto out_put_node; + } - if (size <= sizeof(*list)) - return -EINVAL; + if (size <= sizeof(*list)) { + ret = -EINVAL; + goto out_put_node; + } offset = be32_to_cpup(list); ret = mtd_read(mtd, offset, len, &retlen, dev->eeprom.data); put_mtd_device(mtd); if (ret) - return ret; + goto out_put_node; - if (retlen < len) - return -EINVAL; + if (retlen < len) { + ret = -EINVAL; + goto out_put_node; + } - return 0; +out_put_node: + of_node_put(np); + return ret; #else return -ENOENT; #endif -- 2.19.1