From patchwork Fri Aug 16 10:49:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6IOh6L+e5Yuk?= X-Patchwork-Id: 13765907 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2069.outbound.protection.outlook.com [40.107.215.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3AB5A198A10; Fri, 16 Aug 2024 10:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.69 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723805371; cv=fail; b=KvCaHt/MeghAGkuuFpNGczIJiOSzYOGH07d/caD+qnCcDt7xQ9d3u4za6rUN7HHgZybtgcPBwiFhb0CwHM8SeGugUh/wOKENbftlEGK1Pq7EAqzzZednkhrYJS3nZenJkEZDsEcN7cREjo2CUNsQL5lYSxf2GVCa2FhNthvOJnE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723805371; c=relaxed/simple; bh=Za5yXHLdQi5QePQgSg8icwBkhVof8mayyEPpTw8Dn1k=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=rXluF8n4lmE6SYjhQjv25Mgrz5oX+bId9PLix/XvBl77R4ROUbUBxpt8egEYm6U1NzN7YXe71CG4wvfkr+i2mmGo8JAo+diIr5kOmC8pHmaTOotqLAI6V1AIo8+2tkZ3vcUNsB79ts7BKB2mCV7nVDr7Rvnwp0TTLOzb9uBJ5So= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=ROc4qapO; arc=fail smtp.client-ip=40.107.215.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="ROc4qapO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=oHT+nWDnAYqDEoIFPJXEcSRjysS0mcw6I2BGU6crpBP3R/RKTG2LsurxkfSv+csCIM4gosTQnW+mtdUgKw+B++U90DNAi5wPT931SR2DPtP54vcJefE6gVBmpNtTn/A1IH9L2o1jbRbv+lQKRaznrXreJb9ZvjCxsEhCL0QHGGC8xx7/YDjeSaqAYuo8RG3fLdWwX1HMtmwCGsLRlNIHACFaAfZO2+g9g5kiCs0Wywam+f9WA4TOkRoM4KQ9olfoUcah6oelNL9LTJWMppNXityrKWeq70soi3GldzGH3FDrMLrpJYduicLr50QQ+1wqmaJ1UG/KT4p6T/Ts4qkKxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Za5yXHLdQi5QePQgSg8icwBkhVof8mayyEPpTw8Dn1k=; b=jL5Ol/7tvdMcYhwLCjiRhZkQr3u6iuYYe3mp6QT9LUN0rmy6e9zAQ0yYyrdtnCus6x0tBlseGHmD+sc4TE2epWozGbhx1rBM2w1aLJ7LzeRBxhgUGxMUHTV0OMh0Gt2KgrGniFzMxELovHFmDaDsvSbpRpi0kS8vXNDHY+YkHXvSaAy+A9v3Ngz+QtevJUgD3u5yuffcUQoCQZmCOx09UzadHquG9voOthG804990HcGoXJTGXv4mE3bfB39MYcSWMfPUK6RbuikBdaiKxwpTtceY234TWVOLpQi9LwWNb2B7bpm9k8fK5Q5y5ouGlk/oxdu6gfP+kyZ5DZodIt7BA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Za5yXHLdQi5QePQgSg8icwBkhVof8mayyEPpTw8Dn1k=; b=ROc4qapOwKWNuFil6X56fSrTbd8RdhiKDk3t3zhs6sIhfgVY+vA3WypYmlnlvDqyJKXmKe0u+H9cg0YWO8eebNnR6TQBNR0urHcNfT2WRMSsYV7XC9736kSQQesEMUSRyTO77hfpC/s4pxGzPs6/8NrpurOvtfbR/cVzHtC60P98X24q47/Mrdmqww+MPSG+ymF7imsInU8F+/kIfeo42D6+2TP1SCjCOYMzbY0Qy6XWBvgLkY6SdpEAegjR03d+1WJboTlK+Pk1Y3pCKicRt9BkYGz655hyN1zvZmMrGReyfBjR7Q2EUc1tNvaJz8NhlnVGp7Tfg8M4Tz9Ydw5xUg== Received: from TYUPR06MB6217.apcprd06.prod.outlook.com (2603:1096:400:358::7) by SEZPR06MB5691.apcprd06.prod.outlook.com (2603:1096:101:af::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.17; Fri, 16 Aug 2024 10:49:19 +0000 Received: from TYUPR06MB6217.apcprd06.prod.outlook.com ([fe80::c18d:f7c6:7590:64fe]) by TYUPR06MB6217.apcprd06.prod.outlook.com ([fe80::c18d:f7c6:7590:64fe%4]) with mapi id 15.20.7875.016; Fri, 16 Aug 2024 10:49:19 +0000 From: =?eucgb2312_cn?b?uvrBrMfa?= To: "gregkh@linuxfoundation.org" , "quic_prashk@quicinc.com" , "quic_jjohnson@quicinc.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: opensource.kernel , "akpm@linux-foundation.org" , =?eucgb2312_cn?b?uvo=?= =?eucgb2312_cn?b?wazH2g==?= Subject: [PATCH] usb: gadget: u_serial: check Null pointer in EP callback Thread-Topic: [PATCH] usb: gadget: u_serial: check Null pointer in EP callback Thread-Index: AdrvyMyJeJV7tcOcTkOYhAFaznDU/w== Date: Fri, 16 Aug 2024 10:49:19 +0000 Message-ID: Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: TYUPR06MB6217:EE_|SEZPR06MB5691:EE_ x-ms-office365-filtering-correlation-id: 49b21422-1c20-4384-164a-08dcbde114ce x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|376014|1800799024|366016|38070700018; x-microsoft-antispam-message-info: =?eucgb2312_cn?b?MmQwZ0pJQWlLem42RHMyZmJqV0hv?= =?eucgb2312_cn?b?eHVzbkcvMW03eXphQkNZTWdXaXB5V0tyUzYvYWhHRkJUa2o3WUpUTmpUdnhIUGlz?= =?eucgb2312_cn?b?QndFMk5HK3cvWW41NmxlaXZhbmVZdEdTOXVzNVYweFpQM2pqWHVWRE5HV04rODcy?= =?eucgb2312_cn?b?OHV6QVhlTGRvOGEwMnlybmdreWJGc25xUmExZEduVWUwN2twKzh6WkZZZksrVEVN?= =?eucgb2312_cn?b?SzBzcDBHQXZQVmxVUVZRSGxHS29WRTRFWlArQ2VqSHZrcXRTSk9HMnpNN3NsOU5k?= =?eucgb2312_cn?b?OGlYRU9sWTJkVkx4M2NwcDJDMGJsUUdhN2ZETmlPV2hrZWRjQ1BYd3A0WkR3bzlr?= =?eucgb2312_cn?b?TmZ5OE9XRjIrT1VyNys2b3E0T1lHUklueXJtY1RDUEhhRVBZb216WnlRSDdzM2dQ?= =?eucgb2312_cn?b?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TFyK2FOUkJnbStQOVFGSXpZVUZWQ013czQrdnh6S3Z5?= =?eucgb2312_cn?b?c0VSakh1RzlsS2wrL1cvU1pKalNFRDRhTWcwcnYzaWNGY3czMkl2elh4ckdsUlN3?= =?eucgb2312_cn?b?S29YWWFRL0F5dzJ3Mi9rTEh0cmorSXkzUFQ4bHpsSEFIT0dqTHp3c21PY255WUh2?= =?eucgb2312_cn?b?ck5nVUZIMjlaazY5Z1ZrdW96VWEzcFA2MUtXQ1N2akVkbFB3NTJZV0NIOVBHTHlU?= =?eucgb2312_cn?b?SHVuZC8yUnBPd2Jnb0ZvREd4NE9tNmx3T0NrdHpHYzFuekN4WEVPanJNckhoTllJ?= =?eucgb2312_cn?b?Y0RkRjA3QnNYQjhpOW1NQ2ZyVGtSYzJJV1E1a0R1bWk0NVYyanQrSnNNN2JYRUVP?= =?eucgb2312_cn?b?Y25keUVSNkNMdXkwYmtGZERJNTJiZllrZHk2d1FSa3h5bWZSbmpraTE1YXh4QWs3?= =?eucgb2312_cn?b?ZHQzcDl0UWViajU0SkR1RXNpZWxSNVNBdndiNldPQWNVMmxhdlZzb2FnaDFsVUNZ?= =?eucgb2312_cn?b?Z3BVZlhzd1hHNmYzWVRIQU4zdGI3V05CSnJrdHozY0lUbGhDUUxWYTBWZXNNZkpN?= =?eucgb2312_cn?b?T2dETDRlRGg1eFUrNUZDeUtYeHdKMjErV0wvTE1uNjcxMldJTVgrV1ZQNFhYVXRX?= =?eucgb2312_cn?b?ZFhKOVBCM0xCR1hSUlVZNVE9PQ==?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:zh-cn;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYUPR06MB6217.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?eucgb2312_cn?b?RGRnRHh1aXJaR2kxe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cn?b?dFduMEZUemxVa2VBZEFNMG9KOEJOdHFqVUZPQ3dkQlRqOGZhcUFHNnVvdE84Q0RZ?= =?eucgb2312_cn?b?U0REQVNXWjRpMDQyZjViUDRrNjJpdlVhaVd4a1M5RG5USGRxMjl2VXhNQmxPN2tC?= =?eucgb2312_cn?b?TjF5NGw3cm9rL2VYZWdxeDB6cGY5MWljTmQ3dXI3WXhvTWVxaTNXWHRoaUtWajJy?= =?eucgb2312_cn?b?Y2w5SjJNSWVHTm5mYzg4dGhPWU05YWdmQ1phMlZFZXFXWjhlU0NjZ0hwSGRid01Y?= =?eucgb2312_cn?b?VVZrWGtyMlliYjg1U3N2NHlVYlczMWlWclJzZ21wV0plVHdncEJTYjU3ekREUHlQ?= =?eucgb2312_cn?b?bXN4ZWZ6RUhFYUdmMTZCWlJvRXIwVDV5WnFtbS9zU2d4SmVtTmJlUS9DUmlBbTlS?= =?eucgb2312_cn?b?emc0NWdMSUdKN3doWkxacUxiVjdGS0N1dz0=?= Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: TYUPR06MB6217.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49b21422-1c20-4384-164a-08dcbde114ce X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2024 10:49:19.3547 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 4/TiFnZ4ylDaK/iWcWSpPXIm/4WTt1hB/JgHRGhFoZFY8z+czh/NB6EqIycQ/ks4RmHhHMRF3CJ6Hiqy5hVnvQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5691 From: Lianqin Hu Added null pointer check to avoid system crash. Unable to handle kernel NULL pointer dereference at virtual address 00000000000001a8 pc : gs_read_complete+0x58/0x240 lr : usb_gadget_giveback_request+0x40/0x160 sp : ffffffc00f1539c0 x29: ffffffc00f1539c0 x28: ffffff8002a30000 x27: 0000000000000000 x26: ffffff8002a30000 x25: 0000000000000000 x24: ffffff8002a30000 x23: ffffff8002ff9a70 x22: ffffff898e7a7b00 x21: ffffff803c9af9d8 x20: ffffff898e7a7b00 x19: 00000000000001a8 x18: ffffffc0099fd098 x17: 0000000000001000 x16: 0000000080000000 x15: 0000000ac1200000 x14: 0000000000000003 x13: 000000000000d5e8 x12: 0000000355c314ac x11: 0000000000000015 x10: 0000000000000012 x9 : 0000000000000008 x8 : 0000000000000000 x7 : 0000000000000000 x6 : ffffff887cd12000 x5 : 0000000000000002 x4 : ffffffc00f9b07f0 x3 : ffffffc00f1538d0 x2 : 0000000000000001 x1 : 0000000000000000 x0 : 00000000000001a8 Call trace: gs_read_complete+0x58/0x240 usb_gadget_giveback_request+0x40/0x160 dwc3_remove_requests+0x170/0x484 dwc3_ep0_out_start+0xb0/0x1d4 __dwc3_gadget_start+0x25c/0x720 kretprobe_trampoline.cfi_jt+0x0/0x8 kretprobe_trampoline.cfi_jt+0x0/0x8 udc_bind_to_driver+0x1d8/0x300 usb_gadget_probe_driver+0xa8/0x1dc gadget_dev_desc_UDC_store+0x13c/0x188 configfs_write_iter+0x160/0x1f4 vfs_write+0x2d0/0x40c ksys_write+0x7c/0xf0 __arm64_sys_write+0x20/0x30 invoke_syscall+0x60/0x150 el0_svc_common+0x8c/0xf8 do_el0_svc+0x28/0xa0 el0_svc+0x24/0x84 el0t_64_sync_handler+0x88/0xec el0t_64_sync+0x1b4/0x1b8 Code: aa1f03e1 aa1303e0 52800022 2a0103e8 (88e87e62) ---[ end trace 938847327a739172 ]--- Kernel panic - not syncing: Oops: Fatal exception Signed-off-by: Lianqin Hu --- drivers/usb/gadget/function/u_serial.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index b394105e55d6..65637d53bf02 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -454,6 +454,14 @@ static void gs_read_complete(struct usb_ep *ep, struct usb_request *req) { struct gs_port *port = ep->driver_data; + /* + * When port is NULL, Return to avoid panic. + */ + if (!port) { + pr_err("%s, failed to get port\n", __func__); + return; + } + /* Queue all received data until the tty layer is ready for it. */ spin_lock(&port->port_lock); list_add_tail(&req->list, &port->read_queue); @@ -465,6 +473,14 @@ static void gs_write_complete(struct usb_ep *ep, struct usb_request *req) { struct gs_port *port = ep->driver_data; + /* + * When port is NULL, Return to avoid panic. + */ + if (!port) { + pr_err("%s, failed to get port\n", __func__); + return; + } + spin_lock(&port->port_lock); list_add(&req->list, &port->write_pool); port->write_started--;