From patchwork Fri Feb 26 22:49:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12107435 X-Patchwork-Delegate: kieran@bingham.xyz 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable 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 952DAC433E6 for ; Fri, 26 Feb 2021 22:51:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B89364F13 for ; Fri, 26 Feb 2021 22:51:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230001AbhBZWux (ORCPT ); Fri, 26 Feb 2021 17:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbhBZWuw (ORCPT ); Fri, 26 Feb 2021 17:50:52 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3783DC06174A; Fri, 26 Feb 2021 14:50:12 -0800 (PST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 591DB8C2; Fri, 26 Feb 2021 23:50:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614379810; bh=m338KCSxr+6lpZlr2Hw3GyKsvcoDSYDUn5BOWKz1KzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XGNpWKYMilkBUWDLKCR5OqgNy1/6Lcm8j+/qgbnyPy66mYvzm/cw4fKO2nTzI5dww Dd9M1S0BeCnEnFXFt/+iYvEqFGH+l+1jZ/g2o1oNh9WGjdcCLUVtKSdYSFi4Venibf DJwojdd4uSOokY+cBFQjUSd6kKhok/6QN46Yf6d4= From: Laurent Pinchart To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus , linux-renesas-soc@vger.kernel.org, Laurent Pinchart Subject: [PATCH 2/2] media: v4l2-async: Safely unregister an non-registered async subdev Date: Sat, 27 Feb 2021 00:49:38 +0200 Message-Id: <20210226224938.18166-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210226224938.18166-1-laurent.pinchart@ideasonboard.com> References: <20210226224938.18166-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org From: Laurent Pinchart Make the V4L2 async framework a bit more robust by allowing to unregister a non-registered async subdev. Otherwise the v4l2_async_cleanup() will attempt to delete the async subdev from the subdev_list with the corresponding list_head not initialized. Signed-off-by: Laurent Pinchart Acked-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 37cc0263b273..2347b7ac54d4 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -750,6 +750,9 @@ EXPORT_SYMBOL(v4l2_async_register_subdev); void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) { + if (list_is_null(&sd->async_list)) + return; + mutex_lock(&list_lock); __v4l2_async_notifier_unregister(sd->subdev_notifier);