Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2401068lqp; Sun, 24 Mar 2024 17:57:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHg8a0zPjsnMqHBPGUFNeFwrxyMDPchNM6v8q6BTQnuuOVGPI0R9/jc/yO4V8/pUWgTM9B1X3Q4gQ7/nbU7qLwSyhT8mpJvrusyqJbYA== X-Google-Smtp-Source: AGHT+IFaRzHK7nUKGcdCQifssg0y/MOiSSrQa67ZQBym68wziHCRHOGGraiDlrR8BkP/st2qbiKr X-Received: by 2002:a17:906:a89a:b0:a47:52c2:96d9 with SMTP id ha26-20020a170906a89a00b00a4752c296d9mr1331067ejb.77.1711328245143; Sun, 24 Mar 2024 17:57:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711328245; cv=pass; d=google.com; s=arc-20160816; b=Pyjdl6YJTs+pIq+yJNdZ7Ww3sp65QqrFtWYcKL0fVDzmwq3bzt6jtkh1D0TV4cwKWx qFeDBSiWQocKpzx7rnUon/DVMbJspsUYif1iWf/NceD98MY5Yg0GfXhKKCzrH1i9P45H jQMIs+lIp0S/qURDCOlenPy8HtOt8Ocf2xPtwCEAeRfdoFotmi3R6oHLejjTml3HeUTq 4QiS0TwR2WoWMj3XvzLvuOvmpupjIQ/Gllc2oXU9LJtags3baGOfeHeJkFD9xVk5bv9J J6W/YtH3sNsn8HOPUn9SYwDObsLiMb7W5F9r+vPoDltI5qxpNIoNR2NLYNj3aJjnmtoO 3LTQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ybEhaPWtvYUM4K582k9AOUzxs/9Yy5ip3cQMDZ3YijM=; fh=ikGKq23wHp81ZtQpYRQgMjqA2uYJsMiMdOXXcuPg2c4=; b=waO50oQYJk5+duRME53bDFQugfT7o3yCBf2knQz3TTJEXKPtbBHQRtU0K+gOkkncVE uhZEKS5yq3mdD09Hk/t1gAPAJ3BWF1ZXEFjYS1/Zh7rHTvTaVl9ClwJPjZDlS0eXG23C mx+ItGyYBDGNPtgyQIljskEPRdrWUHDsl7tD8SQ2N+zfafFStWSOZJGHudiVr8DtSJ3c SPuToPSdZ5HmbmeFQeda2uIzaMn3Wov9sn9D089wmOqCUfDhjGFiXYKNWo80uBhQz4XU d2ft+xPWpiqYJ+UXkkIEBH701x8rGz3i3MDHtgMgo4W65xHzB9OrF0bM1/vNhRUU/HBF Bt9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T6RC1KYW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g9-20020a1709061c8900b00a4a35da50cfsi338223ejh.22.2024.03.24.17.57.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:57:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=T6RC1KYW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113528-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113528-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D458C1F227DA for ; Mon, 25 Mar 2024 00:57:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49C841BF506; Sun, 24 Mar 2024 22:45:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T6RC1KYW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 562C91BEDD1; Sun, 24 Mar 2024 22:45:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320330; cv=none; b=ettySKOIeUN2XzEFmWBbfVfj3VM7Ya6q2mWTT4vl6k/iahIXArTn1tW3dnKZlvmHLt4liCPf086+IYYxwr41nEhuedubtiey+MANHw29Ii+Z/L7YruSz2XiOO6CWkGOxMPuLhFxQ3b/g85YR6XF/8GLX2DxqZQDO8YFnHtchAwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320330; c=relaxed/simple; bh=4BL+nhp8W4vtBjDVb8FRYuXmV/nZ5/pDZL5T4yDC2Cc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ctQVVjm9bUnDJsgFyWfIJuXHSaB7QyVQmAldDHq4uiG5fM5hFYmULWrKFbZEIJzzYelIXgeaoHHVtKIDGKJl5zfGnWBfjV7IJkzmSZquRExOiCIFuDe9zCFRjmJx5C5ODWlgsfw9h8O6sOB0i9dhD8JhIs4PFtx2ZIx/7/aQ9RM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T6RC1KYW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35AC0C433C7; Sun, 24 Mar 2024 22:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320330; bh=4BL+nhp8W4vtBjDVb8FRYuXmV/nZ5/pDZL5T4yDC2Cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T6RC1KYWnUGJ80cgKDbviQW2TegS5A9vP+y6aW4o+IcZVT3wTbS4wVJZFRw1V6dqZ 243B1XeNK2WgYdRu+ZNHi7FRAXvHGo5XCkddM7K82MZrtRK2WKkM6M+O5b9XNgLk3J yvwnibbuBsdGEzDYGLN3YEnv/cOiKQUBkbQx73M4xa63Ha4QxmLsqV8IIrjSO9QPwQ k5cHvdkJVHwo8pX/+owzRS6HO0Qy7MkgF0jwGdtSKuwAjcJOxsflaUyrFNY6ssSqS4 6UoYwiW2Zd3DIppwDuY+rqZsIL6bYGt66ioWR392iBYrStnB6GuzV4MdqUD2NCvUcd AvDgK/B06D/Og== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe JAILLET , Matthias Brugger , AngeloGioacchino Del Regno , Daniel Lezcano , Sasha Levin Subject: [PATCH 6.8 637/715] thermal/drivers/mediatek/lvts_thermal: Fix a memory leak in an error handling path Date: Sun, 24 Mar 2024 18:33:36 -0400 Message-ID: <20240324223455.1342824-638-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Christophe JAILLET [ Upstream commit ca93bf607a44c1f009283dac4af7df0d9ae5e357 ] If devm_krealloc() fails, then 'efuse' is leaking. So free it to avoid a leak. Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") Signed-off-by: Christophe JAILLET Reviewed-by: Matthias Brugger Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/481d345233862d58c3c305855a93d0dbc2bbae7e.1706431063.git.christophe.jaillet@wanadoo.fr Signed-off-by: Sasha Levin --- drivers/thermal/mediatek/lvts_thermal.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c index 98d9c80bd4c62..fd4bd650c77a6 100644 --- a/drivers/thermal/mediatek/lvts_thermal.c +++ b/drivers/thermal/mediatek/lvts_thermal.c @@ -719,8 +719,10 @@ static int lvts_calibration_read(struct device *dev, struct lvts_domain *lvts_td lvts_td->calib = devm_krealloc(dev, lvts_td->calib, lvts_td->calib_len + len, GFP_KERNEL); - if (!lvts_td->calib) + if (!lvts_td->calib) { + kfree(efuse); return -ENOMEM; + } memcpy(lvts_td->calib + lvts_td->calib_len, efuse, len); -- 2.43.0