From patchwork Mon Aug 17 15:14:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B7D3C433DF for ; Mon, 17 Aug 2020 16:02:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56E59208C7 for ; Mon, 17 Aug 2020 16:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680135; bh=B4iLvHS422inQpm20uXUDus5u/N3W7EZbG8sPHI9O4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=uAeMSy5ghn6YnmnvhmAGuhLFqW3dP4qsbO/ljuoRPqeX7PJxll3SvkXqs7QJ9S+Fb ET1I9TCO5UbdwpqPQpRu2rNLJwG+jk55kKJ5t/7SD2s+xwSuRXq7H9DLtFOZq8MI3u oFxsVsj82fuhx9cSS2ufWwSGYMsxQEjyyv0U8Rqw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388173AbgHQQCD (ORCPT ); Mon, 17 Aug 2020 12:02:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:49262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388161AbgHQQBt (ORCPT ); Mon, 17 Aug 2020 12:01:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4142520729; Mon, 17 Aug 2020 16:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680108; bh=B4iLvHS422inQpm20uXUDus5u/N3W7EZbG8sPHI9O4c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yRl3ljUPrghBeA1r/2s2C/uZErVCdqiORSKlJ5Tiim/Ng8CRZgIjJIOUw62kfTpKg IP/tYzb7LqaKdl64y5BcQ9CWc9EBl50B6zUzhc13N9GxLhH4/FhK1OBgJaEXAIo1XJ +MaTJcEY4DLPC5BCCOVJxzvL3pQ3Ib+u+r4cy0bQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeny Novikov , Jani Nikula , Mike Rapoport , Daniel Vetter , Andrew Morton , Bartlomiej Zolnierkiewicz , Sasha Levin Subject: [PATCH 5.4 055/270] video: fbdev: neofb: fix memory leak in neo_scan_monitor() Date: Mon, 17 Aug 2020 17:14:16 +0200 Message-Id: <20200817143758.522143935@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Evgeny Novikov [ Upstream commit edcb3895a751c762a18d25c8d9846ce9759ed7e1 ] neofb_probe() calls neo_scan_monitor() that can successfully allocate a memory for info->monspecs.modedb and proceed to case 0x03. There it does not free the memory and returns -1. neofb_probe() goes to label err_scan_monitor, thus, it does not free this memory through calling fb_destroy_modedb() as well. We can not go to label err_init_hw since neo_scan_monitor() can fail during memory allocation. So, the patch frees the memory directly for case 0x03. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Cc: Jani Nikula Cc: Mike Rapoport Cc: Daniel Vetter Cc: Andrew Morton Signed-off-by: Bartlomiej Zolnierkiewicz Link: https://patchwork.freedesktop.org/patch/msgid/20200630195451.18675-1-novikov@ispras.ru Signed-off-by: Sasha Levin --- drivers/video/fbdev/neofb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index b770946a09206..76464000933d8 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -1820,6 +1820,7 @@ static int neo_scan_monitor(struct fb_info *info) #else printk(KERN_ERR "neofb: Only 640x480, 800x600/480 and 1024x768 panels are currently supported\n"); + kfree(info->monspecs.modedb); return -1; #endif default: