From patchwork Thu Apr 16 13:21:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 227906 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=-9.8 required=3.0 tests=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 03DFAC2BB55 for ; Thu, 16 Apr 2020 13:34:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C339E21D91 for ; Thu, 16 Apr 2020 13:34:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044077; bh=YoydgxVY04JUElx6pTX1WVnIwMMo7Gnp01oStplhfd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=XAJYHTsz4rze5sll85BD+Y+EPGT4QxQLY7IuJUdQNIhimcRKNqGfJJQ8ObujGvBPQ q4D7rquws5Z0T5EQbni2YAmOnllYO2aY0NM9ktQZPtsVfCO0Gy/ne9QnLKwsdFbxAt 0it/6Xz8F3xXXWuT14AObJ505vKiRastLCipqcw8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896959AbgDPNee (ORCPT ); Thu, 16 Apr 2020 09:34:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2896948AbgDPNec (ORCPT ); Thu, 16 Apr 2020 09:34:32 -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 AC26E208E4; Thu, 16 Apr 2020 13:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044072; bh=YoydgxVY04JUElx6pTX1WVnIwMMo7Gnp01oStplhfd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uyNDI+yLHXrV8RS4VhvvSe02Dr8i1Z8hr2U3fmGFuFRUO9mlmG6U2v7tdUrFRfLsu EsGFvXLCQRnbJlzB9j7cGXFycuPpYygr2RoBActuG92nw3NVdbzXKx+9Y3CQb3wPLm /a07ANrbEYZyr9JDjuZT/oYu2g75dpm1spaKzijE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dafna Hirschfeld , Helen Koike , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.5 032/257] media: vimc: streamer: fix memory leak in vimc subdevs if kthread_run fails Date: Thu, 16 Apr 2020 15:21:23 +0200 Message-Id: <20200416131329.976445830@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131325.891903893@linuxfoundation.org> References: <20200416131325.891903893@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: Dafna Hirschfeld [ Upstream commit ceeb2e6166dddf3c9757abbbf84032027e2fa2d2 ] In case kthread_run fails, the vimc subdevices should be notified that streaming stopped so they can release the memory for the streaming. Also, kthread should be set to NULL. Signed-off-by: Dafna Hirschfeld Acked-by: Helen Koike Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/vimc/vimc-streamer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c index cd6b55433c9ee..43e494df61d88 100644 --- a/drivers/media/platform/vimc/vimc-streamer.c +++ b/drivers/media/platform/vimc/vimc-streamer.c @@ -207,8 +207,13 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, stream->kthread = kthread_run(vimc_streamer_thread, stream, "vimc-streamer thread"); - if (IS_ERR(stream->kthread)) - return PTR_ERR(stream->kthread); + if (IS_ERR(stream->kthread)) { + ret = PTR_ERR(stream->kthread); + dev_err(ved->dev, "kthread_run failed with %d\n", ret); + vimc_streamer_pipeline_terminate(stream); + stream->kthread = NULL; + return ret; + } } else { if (!stream->kthread)