Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1139093rdd; Wed, 10 Jan 2024 09:42:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbFY9bIryPRMJuDAPThg8VAjcFDRBRtWQn2xLCRHECk9RZXfqeD5ZI+YDhlAOFokFAwrGf X-Received: by 2002:a17:903:24f:b0:1d5:ac6:7123 with SMTP id j15-20020a170903024f00b001d50ac67123mr1021420plh.19.1704908545688; Wed, 10 Jan 2024 09:42:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704908545; cv=none; d=google.com; s=arc-20160816; b=d0IrzkOw3n0I7Nl1/tKzo9GXfx/VXWjAAgsYXi4PtQGVoNZgnh4bE8vsCSXA+lYdCS xmVye6W70dihx8p9a/zYeCSNiH6aLpRlynSnHnFIfEf8xBoIGGLi3hpDbCAlj+C80zw4 LK4E7Z0I2o2E0xwgSb6WWM0ZVMFeY6+JMeVzoF8CvNPWzScivc1J29fOadaGDd+Qty6P aX/alWIgJJHusNOk2sw8mVqz3QSfTS/Nxw3i4g9sjRe7CsSoj/OgjZ8gr67yQhjQT8Zl 5Vo5C0sdZgH1LWY+KjJmQZ9h5hJU2c4SO3qRBAOxFwIrkVLYnH4uWN+cbhgNbUCvVeK+ fwtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=bLcVR4b30t9K1TjNYadhvfqgYQnB+VOQ5Ntb5Vmzx9w=; fh=mR1j1IVvHEi0jEbdfH0z4VX8hw4ltuoo5vh+ql7sokg=; b=kRobAVCvrPWKu/yf+mWRS20NqHMiPlNwTa/timsDb0LD4RDAFKbOCYupVeqMEvBDgq IWZ/4ilzte4txCGId93YIRsqczCritpSrlrLH31WQdaE5Q82+P/DIHFlakx436J/8lot eVdo+YuYCoWsG5zlwWxx3FMS1TtkD0ulU91AfXY3oRr6yvt40hpKUpA+wLeY8iwYd09w dj6gZxjUQ1CcOZXFG5EsCrtbOP/kemCU2xci/XuwYW0D4MM1VyYrzaBWgRTVMmBMDToI z+gOMrrl8V/nlA2kBhnqD5PyXCDWWuBrWHDFI8ChDfzU6SeLmuayJcZqYAO0BlpiYE0U 7jHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22545-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h6-20020a170902f7c600b001d4726415b6si4176165plw.395.2024.01.10.09.42.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 09:42:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22545-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22545-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AFA55B25BE7 for ; Wed, 10 Jan 2024 17:42:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 96FD04D12D; Wed, 10 Jan 2024 17:41:49 +0000 (UTC) Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 56FF24D102; Wed, 10 Jan 2024 17:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 10 Jan 2024 20:40:06 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 10 Jan 2024 20:40:06 +0300 From: Nikita Zhandarovich To: Mauro Carvalho Chehab CC: Nikita Zhandarovich , , Subject: [PATCH] media: em28xx: return error on media_device_register() failure Date: Wed, 10 Jan 2024 09:39:58 -0800 Message-ID: <20240110173958.4544-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) In an unlikely case of failure in media_device_register(), release resources and return the erroneous value. Otherwise, possible issues with registering the device will continue to be ignored. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 37ecc7b1278f ("[media] em28xx: add media controller support") Signed-off-by: Nikita Zhandarovich --- drivers/media/usb/em28xx/em28xx-cards.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c index 4d037c92af7c..dae731dfc569 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -4095,6 +4095,8 @@ static int em28xx_usb_probe(struct usb_interface *intf, */ #ifdef CONFIG_MEDIA_CONTROLLER retval = media_device_register(dev->media_dev); + if (retval) + goto err_free; #endif return 0;