Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1362850ybb; Fri, 29 Mar 2019 03:04:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6V10hfqrZPX7bU0RGKMx1p5o6bFGisCaH/z68lLk+Dq8YcYTjwkpsxD2c+C6zdCwxatAi X-Received: by 2002:a63:c118:: with SMTP id w24mr44535597pgf.67.1553853840384; Fri, 29 Mar 2019 03:04:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553853840; cv=none; d=google.com; s=arc-20160816; b=yC/q6GHEEtR1Y1MP2ifdwJI1vinFhmmEEuRI758YKpH9+BVMP3VgeZo0NHFlrXcDN/ QDuB8DdfU8CPd9wqkIshTWespjueb01lJEhCthvxp9Aqj35r3ZaJPnAmyxTMMP4rWNhb fXQbb1GcrmmGrbXdEhnp8tyLZx38z+laeUB8LeHVxMGBo91sxVaODtNsYjB3/yNpsY5X l0x/78hW5vuU6YDL9h5bwiLbwyDhnR+VxzoLgMyRhO5NfpFvYC6YyQJEr8bC2bir30Cn tF7myWwhhgLaDraIinCAB4Wn6g1yrLstIx3ueAFpS2jUJlTaFhlUMd42bv2yhbbYPx+h KBZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date; bh=SwPADRW/fhahDJbAsfKfNgP7jn9yqVtNuWXQ1NN18zQ=; b=uN7jE2NQj3OY/t8uP8KDi3+MbZnCWzh0X4UJJUjGiAIGMQDyNE8RTauisx6NqpaQqW 1btLGH94QenVB7cxEG5mXkay/ok1As4GARxzquBcZCxi56ka7/vldXtZnsvCRkHW7ob2 JKZdVATN0goNVBJz+NlrJu+VM4CrXwIGrxWc1Ak2dX7x4JaRyUsMgpPgSRFsJqJSRosT +L3wrxbR0NraIgbNnar/w1OVTg0Kl35pkP+CYwOqdoC3IOs88QFfIfoJsJ+gRT07SU8T X5wEwOwbtF1F0z0nVnwChv5VcAiEmxXTDZKZ5SbUm0fAT/WyewxD9AG0vRwK3y5eC5Oc yowQ== 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 gn11si1479332plb.205.2019.03.29.03.03.44; Fri, 29 Mar 2019 03:04:00 -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; 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 S1729037AbfC2KCj (ORCPT + 99 others); Fri, 29 Mar 2019 06:02:39 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:40783 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726590AbfC2KCj (ORCPT ); Fri, 29 Mar 2019 06:02:39 -0400 X-IronPort-AV: E=Sophos;i="5.60,284,1549954800"; d="scan'208";a="28855835" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES128-SHA; 29 Mar 2019 03:02:38 -0700 Received: from localhost (10.10.76.4) by CHN-SV-EXCH01.mchp-main.com (10.10.76.37) with Microsoft SMTP Server id 14.3.352.0; Fri, 29 Mar 2019 03:02:37 -0700 Date: Fri, 29 Mar 2019 11:02:02 +0100 From: Ludovic Desroches To: Peng Hao CC: , , , Subject: Re: [PATCH] arm/mach-at91/pm : fix possible object reference leak Message-ID: <20190329100202.rupu5xo2prxlcafa@M43218.corp.atmel.com> Mail-Followup-To: Peng Hao , nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <1550069746-85671-1-git-send-email-peng.hao2@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1550069746-85671-1-git-send-email-peng.hao2@zte.com.cn> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Feb 13, 2019 at 10:55:46PM +0800, Peng Hao wrote: > of_find_device_by_node() takes a reference to the struct device > when it finds a match via get_device. When returning error we should > call put_device. > > Signed-off-by: Peng Hao > --- > arch/arm/mach-at91/pm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/arm/mach-at91/pm.c b/arch/arm/mach-at91/pm.c > index 51e808a..70fadb7 100644 > --- a/arch/arm/mach-at91/pm.c > +++ b/arch/arm/mach-at91/pm.c > @@ -621,6 +621,7 @@ static int __init at91_pm_backup_init(void) > > securam_fail: > iounmap(pm_data.sfrbu); > + put_device(&pdev->dev); Fixed in this way, in some cases (as there are goto securam_fail before calling of_find_device_by_node), we may decrement a reference which has not been incremented. Is it safe? Regards Ludovic > pm_data.sfrbu = NULL; > return ret; > } > -- > 1.8.3.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel