From 02b552199a484c61cc44f8337e8c513c062b395e Mon Sep 17 00:00:00 2001 From: wu Date: Wed, 23 Mar 2022 19:27:17 -0700 Subject: [PATCH 1/2] fixed 57ea6b8 from https://gitee.com/zhiminwu123/drivers_adapter_khdf_linux/pulls/280 usb: releases the resource of variable ponits Signed-off-by: wu --- model/usb/device/f_generic.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/model/usb/device/f_generic.c b/model/usb/device/f_generic.c index 1f7ce86..d5f3a7c 100644 --- a/model/usb/device/f_generic.c +++ b/model/usb/device/f_generic.c @@ -1500,6 +1500,7 @@ static long usbfn_ioctl(struct file *file, unsigned int cmd, unsigned long value ret = memcpy_s(ffs->dev_name, MAX_NAMELEN, newfn.name, newfn.nameLen); if (ret != EOK) { + ffs_data_put(ffs); HDF_LOGE("%{public}s:%{public}d memcpy_s failed", __func__, __LINE__); return ret; } @@ -1510,6 +1511,7 @@ static long usbfn_ioctl(struct file *file, unsigned int cmd, unsigned long value } if (sprintf_s(nameEp0, MAX_NAMELEN, "%s.ep%u", ffs->dev_name, 0) < 0) { + ffs_data_put(ffs); return -EFAULT; } ffs_dev = ffs_acquire_dev(newfn.name); @@ -1520,21 +1522,22 @@ static long usbfn_ioctl(struct file *file, unsigned int cmd, unsigned long value ffs->private_data = ffs_dev; ret = alloc_chrdev_region(&g_dev, 0, MAX_EP_DEV, nameEp0); - if (ret < 0) - { + if (ret < 0) { + ffs_release_dev(ffs); + ffs_data_put(ffs); return -EBUSY; } cdev_init(&ffs->cdev, &ffs_ep0_operations); ffs->devno = MKDEV(MAJOR(g_dev), 0); ret = cdev_add(&ffs->cdev, ffs->devno, 1); - if (ret) - { + if (ret) { + ffs_release_dev(ffs); + ffs_data_put(ffs); return -EBUSY; } ffs->fn_device = device_create(ffs_class, NULL, ffs->devno, NULL, nameEp0); - if (IS_ERR(ffs->fn_device)) - { + if (IS_ERR(ffs->fn_device)) { cdev_del(&ffs->cdev); ffs_release_dev(ffs); ffs_data_put(ffs); -- Gitee From 2ed4f29f18efe0de95c7adaaa1e13863c6faba74 Mon Sep 17 00:00:00 2001 From: wu Date: Sat, 19 Mar 2022 01:40:20 -0700 Subject: [PATCH 2/2] fixed 93a7cad from https://gitee.com/zhiminwu123/drivers_adapter_khdf_linux/pulls/280 fix usb null pointer reference Signed-off-by: wu --- model/usb/host/src/usb_pnp_notify.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/model/usb/host/src/usb_pnp_notify.c b/model/usb/host/src/usb_pnp_notify.c index 7e08b37..b7d2fab 100644 --- a/model/usb/host/src/usb_pnp_notify.c +++ b/model/usb/host/src/usb_pnp_notify.c @@ -532,6 +532,11 @@ static int32_t GadgetPnpNotifyHdfSendEvent(const struct HdfDeviceObject *deviceO static int32_t UsbPnpNotifyFirstReport(struct usb_device *usbDev, void *data) { int32_t ret; + if (data == NULL) { + HDF_LOGE("%{pubilc}s:%{pubilc}d data is NULL", __func__, __LINE__); + return HDF_FAILURE; + } + struct HdfDeviceIoClient *client = (struct HdfDeviceIoClient *)data; ret = UsbPnpNotifyHdfSendEvent(client->device, usbDev); -- Gitee