Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2491313pxj; Mon, 10 May 2021 04:23:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgXdGouQc9CiaPYm9lNpdiICQyuo+tZb5hmyDGS422XbbtE6PyfC8Ml3KIXc3GgRWwYPB3 X-Received: by 2002:a02:54c1:: with SMTP id t184mr12020811jaa.79.1620645714821; Mon, 10 May 2021 04:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645714; cv=none; d=google.com; s=arc-20160816; b=qXJbL8m+h9ix/poCf0SsUVMmDZ6GPncqgR1XTtAoB7vKlgi9G1IZrQgBOWZacHDKQt k4HpDjb4g99IY54f2eZfRTps8i8L2ACzuPjpAkb6TLz4OrxCI0TQQOWm6FthGO5/tHmL KxOrg/LdYVsJqLyL7qUroM9nhXIrxKpY1aohfEvlEwjx+hldTbKfIb0m/aT9HYA/day1 yPTX6fOOAEMt6HDw6R2E08yei+G8spk7fW5X98gQm1qtgL0rxLgOgQli+XfvNvYN5woc etYNmwt6w2JerItu30IA/mYx5d2Qn/nKfYwFE8b4dBuOf2SIggYIRZc5WGbe6vl4Oxqy ZHEQ== 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=3AoXnrrKmVEvt/BKqEnnY5A0KeA96WMMgH0qFjoe9uQ=; b=Y/J1J3z6H1GTYQ+PEdLhH0HTBkux+1hd2ufLI37gpDKKdJFj/KOtvqulyCE3M1gnqa bNCdBhBVWVVx+VbrU9GFU5t8v3yFdctvUsBulq5wGWi2d8l/I/aiQUDSGolFF0XoDSgU Jf26k9Cj061pL8h07ZQjbfPIHVelnH0i8M/dREXE9dYYWlZwLe0W0JBqU3m8vGVy+ohX Lu46aeozTxF5V3tQZjfoAWSIBaaV639iD3L4eg5MLqkE3nYRF5wj3agALhVxtzEYrCST iktP/2ipSsFpxsKSvq9pi/AX8UryKaA8FS6v/qjrOrPrWQpR3Sny39KjThJNT5D3iyW3 crBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qon6TASw; 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=pass (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 u12si17075146ilm.67.2021.05.10.04.21.42; Mon, 10 May 2021 04:21:54 -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=@linuxfoundation.org header.s=korg header.b=qon6TASw; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238912AbhEJLU0 (ORCPT + 99 others); Mon, 10 May 2021 07:20:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:52714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234021AbhEJKzs (ORCPT ); Mon, 10 May 2021 06:55:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8CD5D6162A; Mon, 10 May 2021 10:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643409; bh=udtgPzTMLmh5X6gl547QwXfChmJ1KypmNAfux/7KZUs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qon6TASwV/7LNNBbgRJBd4rYbU+YryM+q5GSqAC8jL+YK9HwwZ3DsNatAeDSajgLc UvU0M3lESnmeiZ9RecD++lEDxb+GXEoR9XBkAiJ7djXLMhf4AKs6xptw9Q2PierhMH EkeZWBowV41UThUdq4Uw1CBqIaU7J38r2ezC3hZE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricardo Ribalda , Sakari Ailus , Mauro Carvalho Chehab Subject: [PATCH 5.10 276/299] media: staging/intel-ipu3: Fix memory leak in imu_fmt Date: Mon, 10 May 2021 12:21:13 +0200 Message-Id: <20210510102014.049362370@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Ricardo Ribalda commit 3630901933afba1d16c462b04d569b7576339223 upstream. We are losing the reference to an allocated memory if try. Change the order of the check to avoid that. Cc: stable@vger.kernel.org Fixes: 6d5f26f2e045 ("media: staging/intel-ipu3-v4l: reduce kernel stack usage") Signed-off-by: Ricardo Ribalda Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/ipu3/ipu3-v4l2.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/staging/media/ipu3/ipu3-v4l2.c +++ b/drivers/staging/media/ipu3/ipu3-v4l2.c @@ -693,6 +693,13 @@ static int imgu_fmt(struct imgu_device * if (inode == IMGU_NODE_STAT_3A || inode == IMGU_NODE_PARAMS) continue; + /* CSS expects some format on OUT queue */ + if (i != IPU3_CSS_QUEUE_OUT && + !imgu_pipe->nodes[inode].enabled) { + fmts[i] = NULL; + continue; + } + if (try) { fmts[i] = kmemdup(&imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp, sizeof(struct v4l2_pix_format_mplane), @@ -705,10 +712,6 @@ static int imgu_fmt(struct imgu_device * fmts[i] = &imgu_pipe->nodes[inode].vdev_fmt.fmt.pix_mp; } - /* CSS expects some format on OUT queue */ - if (i != IPU3_CSS_QUEUE_OUT && - !imgu_pipe->nodes[inode].enabled) - fmts[i] = NULL; } if (!try) {