Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2281043ybl; Thu, 19 Dec 2019 10:57:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxLJNqYegD4xWXQiqlss8+jpnz8G3fFSht1YTVKNRifraeqZ4tyNCAyP7sdQV33LlvuZtZE X-Received: by 2002:a05:6830:2006:: with SMTP id e6mr9730496otp.367.1576781842127; Thu, 19 Dec 2019 10:57:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781842; cv=none; d=google.com; s=arc-20160816; b=qNr+Ffwj/nDzGZVbx48s0i677h6rcDL5bIp4Wt939TV3renwuoYAUs4FT7wxWjIgdN +GLhI663+6KEFpxxn0NL6yTYCc8iZbwi763Nfp4ok/l34fQbYYn3ai4RAm/UsFkfp5PQ CB4NJiPH7Se0q2bmY71d4wfSpxDzV5HoznS+88COSfCw3LkRYo9lwmJ5yV+9DLCw2Riq 32OcPpQl7QLL22hHor1TrVJSMR4FPkU7/J57nQlhd5Br1isZkQFIRm2Yr39vgrHZ5/EY rybDcZtOc5BbDvvBDsanukDjvtQxne0a4D2Wrs+xGufW9HHu+gtVcOzUCIAyaCYIVm/u urFA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1iR/HTVyJnNzw5B152+OZlSrif6K2BdI1ugwLHH4jFs=; b=CAayVfJ7osWFoPZ6UFcxC4Y5Q7OGJbt07We7h8aWei3OxS0SGTGbIifWyyz3kVEpNX 4s1UqWz1fsN/fcutSH/0uVBbDajUnMXMQncENXnSu0B9ZE+ruHrEMeVpt2bJBw31guku ebu/QWHbgo8mRwVIqkCM7amebKC/X/cfT83A+HTOqJA7hkPDzmtYDCuGBdv26yyLJB3/ GmnWe7sDPY8FDii/VqfHf/BLNHc0G08uj7a1vtZhFfdB1A8e65FB5iQl88g10dvTNaTT MSuy362ojf7wa96mMm1jrpwDokif2hjRSAOHI3XmnGB+yDjYS/i5B9wtHiHOSgvoQhG3 Fqsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LCrTOVpE; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m24si3749217otn.67.2019.12.19.10.57.11; Thu, 19 Dec 2019 10:57:22 -0800 (PST) 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=@kernel.org header.s=default header.b=LCrTOVpE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730576AbfLSSyz (ORCPT + 99 others); Thu, 19 Dec 2019 13:54:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:50476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730565AbfLSSyx (ORCPT ); Thu, 19 Dec 2019 13:54:53 -0500 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 311B8206EC; Thu, 19 Dec 2019 18:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781692; bh=li7Me4Z/dXWOeP5CzgaRWZCcBrs4ZHrbXmgR707Su98=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCrTOVpEAQAait+UnFSjEPadiTR0WXTKElWSHn9ubfxEbzFAZ6/QSy9DdDtPfoaMI +l3lNf404SjeIKcB7I9wB5xvYjWaYBhFwoLscoPIazOooDKqjvsGS3F/PUKYnG/I3y 7DJYdaBjKfGkh7mpaBMvUVmkDgBq+HURwsegaT0k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Daniel Vetter Subject: [PATCH 5.4 42/80] dma-buf: Fix memory leak in sync_file_merge() Date: Thu, 19 Dec 2019 19:34:34 +0100 Message-Id: <20191219183110.617057484@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 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: Navid Emamdoost commit 6645d42d79d33e8a9fe262660a75d5f4556bbea9 upstream. In the implementation of sync_file_merge() the allocated sync_file is leaked if number of fences overflows. Release sync_file by goto err. Fixes: a02b9dc90d84 ("dma-buf/sync_file: refactor fence storage in struct sync_file") Signed-off-by: Navid Emamdoost Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20191122220957.30427-1-navid.emamdoost@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/dma-buf/sync_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/dma-buf/sync_file.c +++ b/drivers/dma-buf/sync_file.c @@ -221,7 +221,7 @@ static struct sync_file *sync_file_merge a_fences = get_fences(a, &a_num_fences); b_fences = get_fences(b, &b_num_fences); if (a_num_fences > INT_MAX - b_num_fences) - return NULL; + goto err; num_fences = a_num_fences + b_num_fences;