Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1223463pxx; Tue, 27 Oct 2020 11:07:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvvY1PcKzaA+bqc9ADcNf8sQQSoS1LL52KysUtd4oOGb1EoHIZ3yb3aqfUO9eV52jUTbjK X-Received: by 2002:a17:906:1cca:: with SMTP id i10mr3683013ejh.487.1603822038527; Tue, 27 Oct 2020 11:07:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603822038; cv=none; d=google.com; s=arc-20160816; b=0zQXVY/0H8pqsWTCW5NfycwgG4w0xEYZe9HYB8648quSnGTaw+HE3M9aEqPjYpiXJA 756w9aStPTWI+tGbhjeoI7GHNsy0CRJh7Z9IZTu3w/k49bWR55lkL/CxesG/uDmpgcZa 8x2pV5Yj7TsdR2DpAAIVwE74yvi3SQsTBzeErHgprv6IUYlYMORTN+BTLX4NLq8MGm7Y HDMzcI65iXCJh1x/7cCQ5uZg9IdVdvRh1rusQYCLDHgIZ2BX0wE2V7s1S4c6YYm4BwZM zD7wlTaU16xy25ma17DMW3Xu+5wlJWpgBlc3j18/k9kntFR+TCrqSNuUHhtH6uoIf2sC u2Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4LS8GCxjgqy0S6jZm5M0VpNtXAaLRAmR8bV9JBPto8s=; b=CCDVJnnkhWxoGP2kH7kMjqkc46pF9KReFB1eTcs2YdJX6Q052JGIprqQg7MmrnIFf/ OlzMh/PEg7SDxncwaAkkWI6/pZZ66Y924pQUuJv60/s28H91UoKZTsEb7r2W7UCgwcnM iInYyKVInUzSHWwmADINmQEbYUt3axTsCN2fNm/QVNPHuzYSiQxZ/oH9HkMfkbBd0FmG NB0U+CB0uEYlELn9X7xpLhEt5Xem7SaxW7eQCAZp8P2pYPlVLIvcgq9Nmb67KOTnYAw0 W9dg+MEASmVVokdrVjTR64hqRPSbRuKIeBoGrmDHYmySYMzTSNyK4nGOzxzYL0njOi5w BzJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dy0enMGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si1498690eds.110.2020.10.27.11.06.56; Tue, 27 Oct 2020 11:07:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dy0enMGH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1820866AbgJ0Rj0 (ORCPT + 99 others); Tue, 27 Oct 2020 13:39:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:32818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760218AbgJ0OeC (ORCPT ); Tue, 27 Oct 2020 10:34:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CCF1207BB; Tue, 27 Oct 2020 14:34:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603809242; bh=1Y364duatBBUJCxU9Qrrav/P6SMu/GedhHQJqpgaBcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dy0enMGHXsLcZRqZH+ZDxg+Q4e4L5juGSya2x0ZC4odotAmlZuPM61wHXtlKL43fp SuEPqNsKg6PE0oY2FKaGy535PoD1WVo9VypsZo4jEahIgJfa3ek2rx7fgD9VGAIO/H 1Qh4p0QUuH2EGaBfN1BDfCnOzK+EAug7AyWX8c7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Laurent Pinchart , Daniel Vetter , Sasha Levin Subject: [PATCH 5.4 127/408] drm/crc-debugfs: Fix memleak in crc_control_write Date: Tue, 27 Oct 2020 14:51:05 +0100 Message-Id: <20201027135500.989201679@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit f7ec68b341dbd5da13d4c65ce444dcd605f1c42e ] When verify_crc_source() fails, source needs to be freed. However, current code is returning directly and ends up leaking memory. Fixes: d5cc15a0c66e ("drm: crc: Introduce verify_crc_source callback") Signed-off-by: Dinghao Liu Reviewed-by: Laurent Pinchart [danvet: change Fixes: tag per Laurent's review] Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20200819082228.26847-1-dinghao.liu@zju.edu.cn Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_debugfs_crc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_debugfs_crc.c b/drivers/gpu/drm/drm_debugfs_crc.c index 6a626c82e264b..f6598c5a9a879 100644 --- a/drivers/gpu/drm/drm_debugfs_crc.c +++ b/drivers/gpu/drm/drm_debugfs_crc.c @@ -144,8 +144,10 @@ static ssize_t crc_control_write(struct file *file, const char __user *ubuf, source[len - 1] = '\0'; ret = crtc->funcs->verify_crc_source(crtc, source, &values_cnt); - if (ret) + if (ret) { + kfree(source); return ret; + } spin_lock_irq(&crc->lock); -- 2.25.1