mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-01 05:45:45 +00:00
comms/opencbm-kmod: Add error handling for copyin() and copyout() calls
This will be required soon as my intent is to annotate copyin() and related functions with __result_use_check. Moreover, the lack of error handling here is a real bug. The patch was submitted upstream as well. PR: 275986 Approved by: zirias Differential Revision: https://reviews.freebsd.org/D43273
This commit is contained in:
parent
570210a8e8
commit
eaa12eb57a
@ -1,5 +1,6 @@
|
||||
PORTNAME= opencbm-kmod
|
||||
PORTVERSION= ${OCBM_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= comms archivers
|
||||
|
||||
MAINTAINER= zirias@FreeBSD.org
|
||||
|
@ -1,34 +0,0 @@
|
||||
From 6e438c1b32d39e5238f65246e192c89b22fdfd82 Mon Sep 17 00:00:00 2001
|
||||
From: John Baldwin <jhb@FreeBSD.org>
|
||||
Date: Fri, 20 May 2022 17:10:09 +0000
|
||||
Subject: [PATCH] FreeBSD kernel driver: compat with 14-CURRENT
|
||||
|
||||
In 14-CURRENT (upcoming major release), there was a slight change to the
|
||||
driver API at version 1400058.
|
||||
|
||||
Add conditional code to retain compatibility.
|
||||
--- opencbm.c.orig 2022-01-22 22:01:25 UTC
|
||||
+++ opencbm.c
|
||||
@@ -133,8 +133,6 @@ static struct cdevsw cbm_cdevsw = {
|
||||
.d_name = CBM_NAME
|
||||
};
|
||||
|
||||
-static devclass_t cbm_devclass;
|
||||
-
|
||||
/* forward references for parallel burst routines */
|
||||
int cbm_parallel_burst_read_track(struct cbm_data *sc, device_t ppbus,
|
||||
unsigned char *buffer);
|
||||
@@ -930,7 +928,13 @@ static driver_t cbm_driver = {
|
||||
sizeof(struct cbm_data)
|
||||
};
|
||||
|
||||
+#if __FreeBSD_version >= 1400058
|
||||
+DRIVER_MODULE(cbm, ppbus, cbm_driver, 0, 0);
|
||||
+#else
|
||||
+static devclass_t cbm_devclass;
|
||||
+
|
||||
DRIVER_MODULE(cbm, ppbus, cbm_driver, cbm_devclass, 0, 0);
|
||||
+#endif
|
||||
MODULE_DEPEND(cbm, ppbus, 1, 1, 1);
|
||||
|
||||
/*
|
54
comms/opencbm-kmod/files/patch-opencbm.c
Normal file
54
comms/opencbm-kmod/files/patch-opencbm.c
Normal file
@ -0,0 +1,54 @@
|
||||
--- opencbm.c.orig 2022-01-22 22:01:25 UTC
|
||||
+++ opencbm.c
|
||||
@@ -133,8 +133,6 @@ static struct cdevsw cbm_cdevsw = {
|
||||
.d_name = CBM_NAME
|
||||
};
|
||||
|
||||
-static devclass_t cbm_devclass;
|
||||
-
|
||||
/* forward references for parallel burst routines */
|
||||
int cbm_parallel_burst_read_track(struct cbm_data *sc, device_t ppbus,
|
||||
unsigned char *buffer);
|
||||
@@ -699,7 +697,7 @@ cbm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
||||
break;
|
||||
}
|
||||
rv = !cbm_parallel_burst_read_track(sc, ppbus, sc->sc_buf);
|
||||
- if (!rv) copyout(sc->sc_buf, val->buffer, BUFFER_SIZE);
|
||||
+ if (!rv) rv = copyout(sc->sc_buf, val->buffer, BUFFER_SIZE);
|
||||
break;
|
||||
|
||||
case CBMCTRL_PARBURST_READ_TRACK_VAR:
|
||||
@@ -710,7 +708,7 @@ cbm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
||||
break;
|
||||
}
|
||||
rv = !cbm_parallel_burst_read_track_var(sc, ppbus, sc->sc_buf);
|
||||
- if (!rv) copyout(sc->sc_buf, val->buffer, BUFFER_SIZE);
|
||||
+ if (!rv) rv = copyout(sc->sc_buf, val->buffer, BUFFER_SIZE);
|
||||
break;
|
||||
|
||||
case CBMCTRL_PARBURST_WRITE_TRACK:
|
||||
@@ -720,7 +718,9 @@ cbm_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
||||
rv = EINVAL;
|
||||
break;
|
||||
}
|
||||
- copyin(val->buffer, sc->sc_buf, val->length);
|
||||
+ rv = copyin(val->buffer, sc->sc_buf, val->length);
|
||||
+ if (rv)
|
||||
+ break;
|
||||
rv = !cbm_parallel_burst_write_track(sc, ppbus,
|
||||
val->buffer, val->length);
|
||||
break;
|
||||
@@ -930,7 +930,13 @@ static driver_t cbm_driver = {
|
||||
sizeof(struct cbm_data)
|
||||
};
|
||||
|
||||
+#if __FreeBSD_version >= 1400058
|
||||
+DRIVER_MODULE(cbm, ppbus, cbm_driver, 0, 0);
|
||||
+#else
|
||||
+static devclass_t cbm_devclass;
|
||||
+
|
||||
DRIVER_MODULE(cbm, ppbus, cbm_driver, cbm_devclass, 0, 0);
|
||||
+#endif
|
||||
MODULE_DEPEND(cbm, ppbus, 1, 1, 1);
|
||||
|
||||
/*
|
Loading…
Reference in New Issue
Block a user