Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1257548imp; Thu, 21 Feb 2019 23:16:46 -0800 (PST) X-Google-Smtp-Source: AHgI3Iba1cFjbF+MKNFXJOLtW+up+uXXXCoCYKRy18z84oltjIV6FdTsGMf/kcGO09twJdbRVhFl X-Received: by 2002:a63:9c1a:: with SMTP id f26mr2618823pge.381.1550819806474; Thu, 21 Feb 2019 23:16:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550819806; cv=none; d=google.com; s=arc-20160816; b=hd1cjab04RNDWxtB8grENfeMcBnXw5kb2p+DfXEx4lZa1uXHsUHQvf7FJCHdBAsiGF wL+QNgl9avGzhZfUBrjNMRC0tPt3umHjOOPwSmkL/hkH0ah3l97EwoF/6EO3AaVpXIaX CZlh58EeO//i1Ii690jMVnDcotKBZXjXyVclIgW8RwJmpImi356jiEQUMBSSBG8rTbuv 6YYMD8XuymSxOxRasZudmaFV2tcb00xnI5TyPVExUMHrG0AKm6XZKh0b765RRs0WsFZ/ 7cd4WmSDLRdJTpD4nsUBjd3pWPDyxis4Px/kGcLCq/8r2437BJ8sJpDEh6tCe3h/rMMP dHIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=g3rzSYX3pgy3sK21hScgy05YA64C1Su+U+1kAEIHKGc=; b=ZcSLTRelyZuqgQJIMRNq00A92Q6NsSqHPn8FF7L12jCiGYGwvngqLYqE3la4ptc640 hMeGjq/gIS8HS/9N0J367vfx4xxW/ChcDa/ecosXbFO0s7Xf1l1d49+WCLDIAJ1m/dXF oBIG1MiLqyzwH/TRmWP6eB2J13BzUy0bZfIKo9JibFJjIf0nsWIA1bedZGw5hcLTUn4n TzL43vmtZ00rblUe0LjVwvRI5Qfk4EU17Tm6uI7I+deRe2L8XN2Ylf86Si6IxyYaGJ6+ P57k9RMs+7jh6RbD7sBapyKjlirmsykTzx7XvW/tPQbKHXrU/WFAB/9VwaHwOZXEeXpl lbYQ== ARC-Authentication-Results: i=1; mx.google.com; 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 r135si723230pfc.123.2019.02.21.23.16.31; Thu, 21 Feb 2019 23:16:46 -0800 (PST) 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; 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 S1726837AbfBVHPx (ORCPT + 99 others); Fri, 22 Feb 2019 02:15:53 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:34840 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbfBVHPu (ORCPT ); Fri, 22 Feb 2019 02:15:50 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 35B44732F508B31BCDC5; Fri, 22 Feb 2019 15:15:44 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x1M7FTGm037387; Fri, 22 Feb 2019 15:15:29 +0800 (GMT-8) (envelope-from wen.yang99@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019022215160783-1228925 ; Fri, 22 Feb 2019 15:16:07 +0800 From: Wen Yang To: linus.walleij@linaro.org Cc: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, nbd@nbd.name, lorenzo.bianconi83@gmail.com, kvalo@codeaurora.org, matthias.bgg@gmail.com, linux-wireless@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, anirudh@xilinx.com, John.Linn@xilinx.com, michal.simek@xilinx.com, wang.yi59@zte.com.cn, Wen Yang Subject: [PATCH 3/5] mt76: fix a leaked reference by adding a missing of_node_put Date: Fri, 22 Feb 2019 15:15:40 +0800 Message-Id: <1550819742-32155-3-git-send-email-wen.yang99@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1550819742-32155-1-git-send-email-wen.yang99@zte.com.cn> References: <1550819742-32155-1-git-send-email-wen.yang99@zte.com.cn> X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-02-22 15:16:08, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-02-22 15:15:14, Serialize complete at 2019-02-22 15:15:14 X-MAIL: mse01.zte.com.cn x1M7FTGm037387 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 530e559..a1529920d 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.9.5