RE: [EXTERNAL] [PATCH net-next v03 1/1] hinic3: module initialization and tx/rx logic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> >+static struct hinic3_adev *hinic3_add_one_adev(struct hinic3_hwdev
> >*hwdev,
> >+					       enum hinic3_service_type svc_type)
> >+{
> >+	struct hinic3_adev *hadev;
> >+	const char *svc_name;
> >+	int ret;
> >+
> >+	hadev =3D kzalloc(sizeof(*hadev), GFP_KERNEL);
> >+	if (!hadev)
> >+		return NULL;
> >+
> >+	svc_name =3D hinic3_adev_devices[svc_type].name;
> >+	hadev->adev.name =3D svc_name;
> >+	hadev->adev.id =3D hwdev->dev_id;
> >+	hadev->adev.dev.parent =3D hwdev->dev;
> >+	hadev->adev.dev.release =3D hinic3_comm_adev_release;
> >+	hadev->svc_type =3D svc_type;
> >+	hadev->hwdev =3D hwdev;
> >+
> >+	ret =3D auxiliary_device_init(&hadev->adev);
> >+	if (ret) {
> >+		dev_err(hwdev->dev, "failed init adev %s %u\n",
> >+			svc_name, hwdev->dev_id);
> >+		kfree(hadev);
> >+		return NULL;
> >+	}
> >+
> >+	ret =3D auxiliary_device_add(&hadev->adev);
> >+	if (ret) {
> >+		dev_err(hwdev->dev, "failed to add adev %s %u\n",
> >+			svc_name, hwdev->dev_id);
> >+		auxiliary_device_uninit(&hadev->adev);

> [Suman] memleak for hadev?

No. Calling auxiliary_device_uninit after a successful
auxiliary_device_init will trigger a call to hinic3_comm_adev_release
that releases the memory.

> >+		return NULL;
> >+	}
> >+
> >+	return hadev;
> >+}
> >+




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux