Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5580587img; Wed, 27 Mar 2019 11:05:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFJe2WrAKZNnoSYnF/vlJp9IYLUiIgex+Oyv9VPrAdzP9kwPFLlpHRx+Nc/WiS9I9C8pKL X-Received: by 2002:a17:902:778a:: with SMTP id o10mr6873285pll.135.1553709928354; Wed, 27 Mar 2019 11:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553709928; cv=none; d=google.com; s=arc-20160816; b=Itpv2seVCRXdWeBjKDk4PB3rJJ0OUWHCb3XykptmtastUof/B5N8U3t9UoEqtoCnJC N8ijk9NP06H0bXfNBNJKjzU2g+ztVsVovozglfxHbi2giuq9weqtMPzztm2F/KOl7t5q XDy/kAhfDkZ1e1p1voKaZbdCfnG1sepH4YHBiktOi+owumYjRWgpq+TIKdSFaVmI2qfE nsXqtTkLbnC5K5+iWPmUSJf1v7hz/Kqq5NsJVwOxt7Fo3mSpyO9ZPBVjA0LaZHD3/ZTz nZA8sjhyDTlLNnnqHp87HOfntGHEYyoi7eSTsr7TuXXMiuRUkyykL1lPaw3mO+huCf/O R8lw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WXnAFYYvU5ODBR3TqP6oYvXb/2NJBIEshqsSeZepees=; b=DMz/jvq8eHnReSk3iMXdIKBp5jthw8MuOFr/E7CFNMr7ex1OZk96FIuTv1Tx4iO0WD /mnSviSCsDTP8g68eqXRYJ7SVxNp2sy/3IBcm4ad0ufMFxgmE5TJy9b5dmAiYCIY+U2F taF2z+2gGM9P6hZtEvL6q77MloEmy7QlyWHs7cR6UNG2XTgH8R1LPV/oJmASLBLb9c34 by6YeCQB3wgA10BzZrAf3xwHmP9yPBp93kP2+gRyxbQru6mkKI394LPJVQs2tQMGYOGY pZVdcFiMZJrP6b2/U56ENG4O+RK6SD10wZwMgZpOWnmzdpyjFxWvCHrSS6cV2FlRvVKx yRBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jy6Fl+hp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si19358043plr.73.2019.03.27.11.05.13; Wed, 27 Mar 2019 11:05:28 -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=Jy6Fl+hp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733052AbfC0SD5 (ORCPT + 99 others); Wed, 27 Mar 2019 14:03:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:44278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732879AbfC0SDx (ORCPT ); Wed, 27 Mar 2019 14:03:53 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 29310217D7; Wed, 27 Mar 2019 18:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709832; bh=Ffqck2aIWABNUq3ZwltuooVhhQ3A2FFCOQHwiHl4c8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jy6Fl+hp/xthAo710DUyJhO5Rvu8qul/7hFcw5HeRxAGQJ7qWVbuFH1hv37pNYwCp U9lc9rFbrK9DTNBFtZSsRGCte7SJuDOn05dCfwqip+VAIfaThrzo9CItLg+Oe6IMzx oGTvfNVfxoooUHkUwDcJYXIYGvVySTzklodpnePA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: 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 AUTOSEL 5.0 064/262] mt76: fix a leaked reference by adding a missing of_node_put Date: Wed, 27 Mar 2019 13:58:39 -0400 Message-Id: <20190327180158.10245-64-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wen Yang [ 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