Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3894629imm; Mon, 30 Jul 2018 05:28:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf8EVKore6GU2PdZhc8TTZwwqSOEPRIBONMVQXN/kR72jzUcWenKtzPyH4/eu5wCZAHJ6F9 X-Received: by 2002:a17:902:683:: with SMTP id 3-v6mr8089779plh.52.1532953738896; Mon, 30 Jul 2018 05:28:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532953738; cv=none; d=google.com; s=arc-20160816; b=pXfsu8xCxPOYP0HrpmMY1xVOTNoDv6FxZk3GBXjQi5qOtoieLYNK/A//4oqwjMLaaf oB7+z3X8yr3RIc0UnjzJYJzk/fPYDVIHLxTtbZzmJ6ndIm5MB2YIfO8uhOyfZWeBNmD9 xlaftudXIq5ks/XWtlpYGcqqacniAPb45d5CmJuAYCKURUGgdXayEsHA8rNns+jw4MKw AoAi1LXWACKiyd23vFsYrjLIHYH/OvT427VxQRQiBr5tHOyR8d6ab6hsaz2Bj9139Cp+ LtYG9p4nhSHrPT9NATFsyHCGInAz9DRxp+C6/SL353m3Vk7hnOA0J0RwSh0shMQvFPJu NNtA== 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 :message-id:date:subject:cc:to:from:arc-authentication-results; bh=WA+PFU7k0SW1AoU63FYVoBsuNve6n5iOi4I8+YCk+2k=; b=iL4yzpgTmU/Bnaoz9QORZAHyCQuCfPzj1JCnCbJj4iogLrFmHBC7XM+bf9Z0E2/CQ/ JUCXsLJLTQQmb3RZTKQyPVNyrN/nMt+V+GRvBXlpX+OC05Rz066Le+jta4tS7evpkvee P8oRYMbcUM+hwR9fORgEBrOhxHa4/KznKuzfCuhd67eBmzEV7uIQYtQLKTwiSKepKbYb mls2NwMOzcKFmmvJ4to3zljQIKmLHzEtBWlVtdVd9Q/Ri4Qfc/UyIH7Hoblf+9RI8vez HwTK7obj81hzpj1Bwk0amyI3C3EjjyGAwc+fPjO6rxcKmtfQsi7VDl/Qc3AVgYSCO9xb kwdg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f62-v6si11969682pfg.165.2018.07.30.05.28.44; Mon, 30 Jul 2018 05:28:58 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729188AbeG3OCD (ORCPT + 99 others); Mon, 30 Jul 2018 10:02:03 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:53062 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbeG3OCD (ORCPT ); Mon, 30 Jul 2018 10:02:03 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fk7Ge-00069W-Rv; Mon, 30 Jul 2018 12:27:16 +0000 From: Colin King To: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] thermal: armada: fix incorrect check for drvdata allocation failure Date: Mon, 30 Jul 2018 13:27:16 +0100 Message-Id: <20180730122716.6267-1-colin.king@canonical.com> X-Mailer: git-send-email 2.17.1 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 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); return -ENOMEM; + } priv->dev = &pdev->dev; priv->data = (struct armada_thermal_data *)match->data; -- 2.17.1