From patchwork Tue Mar 26 08:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anle Pan X-Patchwork-Id: 19800 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CA8B1C0DA4 for ; Tue, 26 Mar 2024 08:38:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AFED9632EA; Tue, 26 Mar 2024 09:38:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=nxp.com header.i=@nxp.com header.b="c0/CBoxz"; dkim-atps=neutral Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on070f.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::70f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D5C063037 for ; Tue, 26 Mar 2024 09:38:22 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aNJF/VIjrsm9MfheIgytLHpLn4KSnYx0TQnSVZWZDJzAYrGqvWuZn1GcBjaa6evRE4N047mQkoJvAMlpmcM6JlodaSeBijxS7ta/GTQRs4JyoQwWHiwiT1aCYzPB7yAFd4DQwWMf0JVbTklh9WjqO3EJ0j4RVnjjc9o6EkMTOMBOhd3alcbwVInhVmwjW1wqWDgEXZ4dD9jPrj8biDmes7Vfd8Di5dq88CaJz07er3rEH9HfZngyV5aGg4Id5scSDNm9gMVML/f+icRXhPb+YvMg/npO+X70NZPUH4HmTVhysklyQ6+fLfODJrQwKs28SjBx0ZWMG8NNI7/cLl+hSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zBqCFH6RI5BWmb2udUNGwpbeWxpStkrTz7Jq5iqH5Ps=; b=UTqSz51oVq7RmKQGmeayeroukmyelBDJiNVBYRWYx6HQxgVUt0VKMPd5uk7gSDYltq/iXl2Eqg7eMyblsyb0q/9CyPdIDtnPOpSjzobZtR3BtHEkHc84iqz3O+yUKziCzFeAfZdgvcC7U7CQw6Ly5iKDMU39v9uOfr2gqqIrxzFQj3xfj5sacCOc3SsRE6SVN/PjQD/Bp35ZgvTfqKBIyQjE5rHFXCl2pz9PikmpvOCGiMnXgyPCpj+Ov1Tfxn06++HGI24JWcpyq9P6g2SerDggdS69w7ijQhj865GvwB+hplifyeHEczgboJxbg4RfBHRm/YOCtL4aE1HTjYtoTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zBqCFH6RI5BWmb2udUNGwpbeWxpStkrTz7Jq5iqH5Ps=; b=c0/CBoxz9VJp+f0gEJ9cq4LhACnBb8OoOK6yoVHGaIb7mIATmzB+Y6a9n5gVN4NYQT5/Ux9Uchz0OG7Pyz6mCCt42qhvpocw6ENG2Ilp1WM6nJj3uvowk13CcGC5Egs8HRw58AkEY0wRWgbpR4B+i1AkWeBF3EVYh0NqQ3Y0VdM= Received: from DU2PR04MB8967.eurprd04.prod.outlook.com (2603:10a6:10:2e2::19) by PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Tue, 26 Mar 2024 08:38:20 +0000 Received: from DU2PR04MB8967.eurprd04.prod.outlook.com ([fe80::863b:1be2:4278:3470]) by DU2PR04MB8967.eurprd04.prod.outlook.com ([fe80::863b:1be2:4278:3470%4]) with mapi id 15.20.7409.031; Tue, 26 Mar 2024 08:38:20 +0000 From: Anle Pan To: libcamera-devel@lists.libcamera.org Cc: hui.fang@nxp.com Subject: [PATCH] libcamera: device_enumerator: exclude uvcvideo device when enumerate Date: Tue, 26 Mar 2024 17:38:04 +0900 Message-Id: <20240326083804.3718161-1-anle.pan@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR04CA0197.apcprd04.prod.outlook.com (2603:1096:4:14::35) To DU2PR04MB8967.eurprd04.prod.outlook.com (2603:10a6:10:2e2::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8967:EE_|PAXPR04MB9642:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U2CDIkpxaoD8gJauGgOjl3l4y9HohMd+pTXTa/E5uEb+pPK9D7WgjAsc8P3+kZS0BU+ZRQ5l/KeMyJor65RS9v20JGxCNUmjVRT5uMW7cSJquFfl7kbJIoPHTYds6AnAUXgLzuctrpFrcBKXMNTQl49hqRG4U7DkWQRx/6ZOjoLWOlOyucMiSdYNxPx8SzgFHF9mV9zJDriejzxkM8wmKYJAj6FWVRCF16kAEomjUt0GG/CRX1byA1sL5MG30oeFk/eEAXS6no+mxQs8Myki5o7J2LxTImb89duQ+UczP/FVH4yDWg6Vy4pnhMLgH6M/MCdezbpjHX1NlcJRV25H+XUELCNqptSzRChnjAFbUkcX1apkP7giIjCfnPxQlXhSwJcMaVZR6MMMW26CGL1Yc/9gCF/vDwD6nHsa1Ay7dV2yBontecq7DkEhLmV5verSiqAHlb+2rGw0vuWCoiVQ/UkLeOMbhp9WEbr1u9c7QRstPoJUDBQyumXm4pK+yVZFw4pIIjBsBzZ9B0fokMiin06q8akI2ZGwvXqTz6PdXZPBquA0L0x4WXtOYOWJbXgaxEeNNB2NQ/eb1VlWeTfjiWLwj5vAoxjqQO7GbxDBXWG9GcGD24MMshQa4jjBpyJld4gbjNyvnZBI007HLTtOIv9I9OIpIfqP1SueZZ0dw0R0w+IsKfFzx7igMgfVNSfitJ4m2HuYhEKXwFnwXMOo7aDbDIRWN07hFvvD91wgP3A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8967.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(366007)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: unCFscZhb0/iHrSgjJk+uaQH1Cao+9ybEwn4Qie/8fE3rOWzlA+cxHX73ybIyBiEl7xOZZBehlXztiEKGVqEkm0dy/yt4DyjmV4Lgn5pJnMgj1ol4iU1N5Dcvi1H9I47+g1pjn7nbK2J2cNrKusds+y8jAvYDTcBT4I8lkMd9PSbSDSr/jZ5cQGCNyWB81KhdM6mO4A2kJpKSGOK6nsTYrsVspho+UB+1+waj8oEexZ7od/vjQItECeDibFEaRcBh1x2gZ90pNYyshbFl2mi2QfPTAyayj8zYI1I9Rtn3CNdwI59Ru9b72N3GHO6mN8PszynVgj+SJOA9dsl20gfIGJJSNE6/iP+8vJWV1MFGiIxCPYKyQeQ77RUAXZSwN5gf4azksGmU7uTRdO1G2VkiwxtoDxN05MryQ7UVC2XCrNRzQ0yP2WCsN8ZOTMP3m9qLl3jLgR3c1z/3RoDEikqBsNvdX2/S43f4qpq4eUbvVYyXNArBSJLKnPWsPETG1QONg/xkvA8yQjVXV4wmmGotnLjifN0qJgrKby+oun8KMRvwi+DdV6cE9uaBMJqxe26CY6/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777 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8967.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2024 08:38:20.6738 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ETXCfHzqD24GpNg85cuATLki0FZYREpAe5lzEqry5PXWmieZIYxskxTggpL/7TvNZLNogkayNtLT0c6GXr1kHQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9642 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Camera service startup crash when camera and usb camera are connected at the same time, service will always reboot due to the null pointer in populateEntities. In this case, a UVC device was used to populate the related entities, pads and links, which was not reasonable. To fix the issue, ensure the media node is not a "uvcvideo" device when enumerate before createDevice. Change-Id: I656a542e83449df287d34a4e358ae2e26e784f17 Signed-off-by: Anle Pan --- src/libcamera/device_enumerator_sysfs.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp index 9979d68a..224ec8c8 100644 --- a/src/libcamera/device_enumerator_sysfs.cpp +++ b/src/libcamera/device_enumerator_sysfs.cpp @@ -73,6 +73,27 @@ int DeviceEnumeratorSysfs::enumerate() continue; } + /* Check that the device node not a uvcvideo. */ + struct media_device_info devinfo; + int fd = open(devnode.c_str(), O_RDWR | O_CLOEXEC); + if (fd < 0) { + LOG(DeviceEnumerator, Warning) + << "Failed to open media device:" + devnode + << " (" << strerror(errno) << "), skipping"; + continue; + } + int retval = ioctl(fd, MEDIA_IOC_DEVICE_INFO, &devinfo); + close(fd); + if (retval != 0) { + LOG(DeviceEnumerator, Warning) + << "Failed to get info from device:" + devnode + << " (" << strerror(errno) << "), skipping"; + continue; + } + if (strstr("uvcvideo", devinfo.driver)) { + continue; + } + std::unique_ptr media = createDevice(devnode); if (!media) continue;