Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4013188imm; Mon, 30 Jul 2018 07:16:23 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdyj/DdnX4PwrJfPVeIvDDqlSt+bnRVVluW8YguRJTBzjocR614x59zO5vM6EMcqqATTHEe X-Received: by 2002:aa7:800f:: with SMTP id j15-v6mr17994086pfi.174.1532960183654; Mon, 30 Jul 2018 07:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532960183; cv=none; d=google.com; s=arc-20160816; b=TmjZKav7Y5Vc3x2kgyc54m2bn7dc9iOxOi2kgrJ8gCI1Fb67bP9cDwJcOHXcqZLsP9 8YtkVeZdSWpP2TZjViv2xbDFJoTCkNkQ17nTMQkQUwsa2h3z/J9C8Yk/750Ua7Xo5n8j 6F99C3sa5DWUOq6JmCH6RJgGfpJhhpvFGTtltohZhLJJ1dY+dEgmwZo72lI7XYy17TSH hPQb6lpCMUxiIV2HKKRWeycnyO9i/0HOCaEk+PWTofI4mMryPnHeOG0G8F5bLE5n8fff 2qiTuppnN5aPlWpEOCGosPUcSVHZ3AqBR+JhlnoAvkGT04GPFws1s399H05uxFIumYfQ OVhw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=n3eJlqfm7xqMB5Btksh9Lv/pCCHQqbI9bADbWEs/zl8=; b=f7kLQeIgH4pi7iwuccPSo45ExuL5l01WgWeMu2o9oM6SfHHBlT+iqPr23MLKiJopSc Na+WHCd/8y6idmRdqB4qTzRWhoQkJ1TVCpcVDo8sDlTz8bOI/ecEz7cNz74PAHav9bmE FKnb5hLfCOXichJqpwzAGuwOpshrX7LjizxHiPUIbxZO9eCIWQ98ttVQyFJY4JFn8lps WUV69FGJ6t2nmnkGUFsa3PnEC8mpGzFg4iYfSKh4gy/60kqn4ivPHYFsocSwCmOi3UMF 4YUFm5OaKgkOsE3GfOMyH8IpySl0e1V7jcKnbqHSZWc1B4Mqua2KqaVfAsSZQk7s5/E2 DY3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a0xxq581; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6-v6si11124706pfy.140.2018.07.30.07.16.09; Mon, 30 Jul 2018 07:16:23 -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=@linaro.org header.s=google header.b=a0xxq581; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731783AbeG3PuT (ORCPT + 99 others); Mon, 30 Jul 2018 11:50:19 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35764 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731600AbeG3PuT (ORCPT ); Mon, 30 Jul 2018 11:50:19 -0400 Received: by mail-wm0-f66.google.com with SMTP id o18-v6so14024953wmc.0 for ; Mon, 30 Jul 2018 07:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=n3eJlqfm7xqMB5Btksh9Lv/pCCHQqbI9bADbWEs/zl8=; b=a0xxq581SJ+pyB6F/V2s8vCC/9qvhMiPA9vTvLDVJAhR2pXBX5OV3i6y5rNjrmkaYY j0aR4D5nUNp3lHcIV5w9b6r6mqgsFPukICB1sq643ydPOLXUxIuC0MKFvpnnZQPu5nj7 mPyPXsjuLX7Q6b2tg0Z/khVcyd99i0tzRl734= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=n3eJlqfm7xqMB5Btksh9Lv/pCCHQqbI9bADbWEs/zl8=; b=X9ysZ1Kak2qX/Gmp3pF1Dm179lamkHL215g74Fa9fA3tKsOxxPs9+biqvEIbEZt8TI X8PgH6RONnGEt7WRQAMqAggohaBeiXbPMnf7/43eRDUbFT74k3+ttzVpdL2Ag0Tpk9rj PO9IXG+NFIZZnHxgkpSyNS0ufbMxXOjrErD0xzH0vTgw2Px3EBJd3qWjcVt1z1JKIu5n dg0Mne9TL//JSUCo2LLJurfSiBT3aemlgLtkzqiMilCPOaN86BpbvGvZCOOO37SUaHvN Ax/OkRicxxnhB4wloI9zgbqnldu3Q8Uud+BLA/AbvhWaJcpNog/KjHzbGZvED3WzXEzY re+Q== X-Gm-Message-State: AOUpUlGe3KkzGF3KOzFEe3nffN6lzAU+UWXT8WKzUANaiRF012T3cyfN 7d0XtKAGhIkx81O4FF1n8FyfsbxsRdQ= X-Received: by 2002:a1c:15ce:: with SMTP id 197-v6mr14674187wmv.99.1532960105198; Mon, 30 Jul 2018 07:15:05 -0700 (PDT) Received: from [192.168.0.22] (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.googlemail.com with ESMTPSA id z11-v6sm25192251wrm.94.2018.07.30.07.15.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Jul 2018 07:15:04 -0700 (PDT) Subject: Re: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure To: Colin King , Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180730122716.6267-1-colin.king@canonical.com> From: Daniel Lezcano Message-ID: Date: Mon, 30 Jul 2018 16:14:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180730122716.6267-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Colin, On 30/07/2018 14:27, Colin King wrote: > From: Colin Ian King > > Currently the drvdata allocation failure is being incorrectly checked by > checking priv and not drvdata. Fix this and also free priv to fix a > memory leak. > > Detected by Coverity Scan, CID#1472102 ("Logically dead code") > > Fixes: c9899c183921 ("thermal: armada: use the resource managed registration helper alternative") > Signed-off-by: Colin Ian King > --- > drivers/thermal/armada_thermal.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c > index 4164a5a4e480..b164fd9f21ac 100644 > --- a/drivers/thermal/armada_thermal.c > +++ b/drivers/thermal/armada_thermal.c > @@ -611,8 +611,10 @@ static int armada_thermal_probe(struct platform_device *pdev) > return -ENOMEM; > > drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); > - if (!priv) > + if (!drvdata) { > + devm_kfree(&pdev->dev, priv); This is not necessary, resources will be free when the driver is destroyed after the probe fails. > return -ENOMEM; > + } > > priv->dev = &pdev->dev; > priv->data = (struct armada_thermal_data *)match->data; Thanks for sending this fix. However, another fix was already submitted for this. -- Daniel -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog