Skip to content

Commit 27563ab

Browse files
committed
Merge tag 'char-misc-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc driver fixes from Greg KH: "Here are some small char and misc and other driver subsystem fixes for 5.9-rc3. The majority of these are tiny habanalabs driver fixes, but also in here are: - speakup build fixes now that it is out of staging and got exposed to more build systems all of a sudden - mei driver fix All of these have been in linux-next for a while with no reported issues" * tag 'char-misc-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: habanalabs: correctly report inbound pci region cfg error habanalabs: check correct vmalloc return code habanalabs: validate FW file size habanalabs: fix incorrect check on failed workqueue create habanalabs: set max power according to card type habanalabs: proper handling of alloc size in coresight habanalabs: set clock gating according to mask habanalabs: verify user input in cs_ioctl_signal_wait habanalabs: Fix a loop in gaudi_extract_ecc_info() habanalabs: Fix memory corruption in debugfs habanalabs: validate packet id during CB parse habanalabs: Validate user address before mapping habanalabs: unmap PCI bars upon iATU failure mei: hdcp: fix mei_hdcp_verify_mprime() input parameter speakup: only build serialio when ISA is enabled speakup: Fix wait_for_xmitr for ttyio case
2 parents 51c4518 + 9c97cec commit 27563ab

23 files changed

Lines changed: 226 additions & 73 deletions

drivers/accessibility/speakup/Kconfig

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ config SPEAKUP
4242
one of the listed synthesizers, you should say n.
4343

4444
if SPEAKUP
45+
46+
config SPEAKUP_SERIALIO
47+
def_bool y
48+
depends on ISA || COMPILE_TEST
49+
4550
config SPEAKUP_SYNTH_ACNTSA
4651
tristate "Accent SA synthesizer support"
4752
help
@@ -52,7 +57,7 @@ config SPEAKUP_SYNTH_ACNTSA
5257

5358
config SPEAKUP_SYNTH_ACNTPC
5459
tristate "Accent PC synthesizer support"
55-
depends on ISA || COMPILE_TEST
60+
depends on SPEAKUP_SERIALIO
5661
help
5762
This is the Speakup driver for the accent pc
5863
synthesizer. You can say y to build it into the kernel,
@@ -104,7 +109,7 @@ config SPEAKUP_SYNTH_DECEXT
104109

105110
config SPEAKUP_SYNTH_DECPC
106111
depends on m
107-
depends on ISA || COMPILE_TEST
112+
depends on SPEAKUP_SERIALIO
108113
tristate "DECtalk PC (big ISA card) synthesizer support"
109114
help
110115

@@ -127,7 +132,7 @@ config SPEAKUP_SYNTH_DECPC
127132

128133
config SPEAKUP_SYNTH_DTLK
129134
tristate "DoubleTalk PC synthesizer support"
130-
depends on ISA || COMPILE_TEST
135+
depends on SPEAKUP_SERIALIO
131136
help
132137

133138
This is the Speakup driver for the internal DoubleTalk
@@ -138,7 +143,7 @@ config SPEAKUP_SYNTH_DTLK
138143

139144
config SPEAKUP_SYNTH_KEYPC
140145
tristate "Keynote Gold PC synthesizer support"
141-
depends on ISA || COMPILE_TEST
146+
depends on SPEAKUP_SERIALIO
142147
help
143148

144149
This is the Speakup driver for the Keynote Gold

drivers/accessibility/speakup/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ speakup-y := \
2525
keyhelp.o \
2626
kobjects.o \
2727
selection.o \
28-
serialio.o \
2928
spk_ttyio.o \
3029
synth.o \
3130
thread.o \
3231
varhandlers.o
32+
speakup-$(CONFIG_SPEAKUP_SERIALIO) += serialio.o

drivers/accessibility/speakup/serialio.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static void spk_serial_tiocmset(unsigned int set, unsigned int clear);
3232
static unsigned char spk_serial_in(void);
3333
static unsigned char spk_serial_in_nowait(void);
3434
static void spk_serial_flush_buffer(void);
35+
static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth);
3536

3637
struct spk_io_ops spk_serial_io_ops = {
3738
.synth_out = spk_serial_out,
@@ -40,6 +41,7 @@ struct spk_io_ops spk_serial_io_ops = {
4041
.synth_in = spk_serial_in,
4142
.synth_in_nowait = spk_serial_in_nowait,
4243
.flush_buffer = spk_serial_flush_buffer,
44+
.wait_for_xmitr = spk_serial_wait_for_xmitr,
4345
};
4446
EXPORT_SYMBOL_GPL(spk_serial_io_ops);
4547

@@ -211,7 +213,7 @@ void spk_stop_serial_interrupt(void)
211213
}
212214
EXPORT_SYMBOL_GPL(spk_stop_serial_interrupt);
213215

214-
int spk_wait_for_xmitr(struct spk_synth *in_synth)
216+
static int spk_serial_wait_for_xmitr(struct spk_synth *in_synth)
215217
{
216218
int tmout = SPK_XMITR_TIMEOUT;
217219

@@ -280,7 +282,7 @@ static void spk_serial_flush_buffer(void)
280282

281283
static int spk_serial_out(struct spk_synth *in_synth, const char ch)
282284
{
283-
if (in_synth->alive && spk_wait_for_xmitr(in_synth)) {
285+
if (in_synth->alive && spk_serial_wait_for_xmitr(in_synth)) {
284286
outb_p(ch, speakup_info.port_tts);
285287
return 1;
286288
}
@@ -295,7 +297,7 @@ const char *spk_serial_synth_immediate(struct spk_synth *synth,
295297
while ((ch = *buff)) {
296298
if (ch == '\n')
297299
ch = synth->procspeech;
298-
if (spk_wait_for_xmitr(synth))
300+
if (spk_serial_wait_for_xmitr(synth))
299301
outb(ch, speakup_info.port_tts);
300302
else
301303
return buff;

drivers/accessibility/speakup/spk_priv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434

3535
const struct old_serial_port *spk_serial_init(int index);
3636
void spk_stop_serial_interrupt(void);
37-
int spk_wait_for_xmitr(struct spk_synth *in_synth);
3837
void spk_serial_release(void);
3938
void spk_ttyio_release(void);
4039
void spk_ttyio_register_ldisc(void);

drivers/accessibility/speakup/spk_ttyio.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear);
116116
static unsigned char spk_ttyio_in(void);
117117
static unsigned char spk_ttyio_in_nowait(void);
118118
static void spk_ttyio_flush_buffer(void);
119+
static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth);
119120

120121
struct spk_io_ops spk_ttyio_ops = {
121122
.synth_out = spk_ttyio_out,
@@ -125,6 +126,7 @@ struct spk_io_ops spk_ttyio_ops = {
125126
.synth_in = spk_ttyio_in,
126127
.synth_in_nowait = spk_ttyio_in_nowait,
127128
.flush_buffer = spk_ttyio_flush_buffer,
129+
.wait_for_xmitr = spk_ttyio_wait_for_xmitr,
128130
};
129131
EXPORT_SYMBOL_GPL(spk_ttyio_ops);
130132

@@ -286,6 +288,11 @@ static void spk_ttyio_tiocmset(unsigned int set, unsigned int clear)
286288
mutex_unlock(&speakup_tty_mutex);
287289
}
288290

291+
static int spk_ttyio_wait_for_xmitr(struct spk_synth *in_synth)
292+
{
293+
return 1;
294+
}
295+
289296
static unsigned char ttyio_in(int timeout)
290297
{
291298
struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;

drivers/accessibility/speakup/spk_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct spk_io_ops {
158158
unsigned char (*synth_in)(void);
159159
unsigned char (*synth_in_nowait)(void);
160160
void (*flush_buffer)(void);
161+
int (*wait_for_xmitr)(struct spk_synth *synth);
161162
};
162163

163164
struct spk_synth {

drivers/accessibility/speakup/synth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int spk_synth_is_alive_restart(struct spk_synth *synth)
159159
{
160160
if (synth->alive)
161161
return 1;
162-
if (spk_wait_for_xmitr(synth) > 0) {
162+
if (synth->io_ops->wait_for_xmitr(synth) > 0) {
163163
/* restart */
164164
synth->alive = 1;
165165
synth_printf("%s", synth->init);

drivers/misc/habanalabs/common/command_buffer.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/mm.h>
1212
#include <linux/slab.h>
13+
#include <linux/uaccess.h>
1314
#include <linux/genalloc.h>
1415

1516
static void cb_fini(struct hl_device *hdev, struct hl_cb *cb)
@@ -300,7 +301,7 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
300301
struct hl_device *hdev = hpriv->hdev;
301302
struct hl_cb *cb;
302303
phys_addr_t address;
303-
u32 handle;
304+
u32 handle, user_cb_size;
304305
int rc;
305306

306307
handle = vma->vm_pgoff;
@@ -314,14 +315,25 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
314315
}
315316

316317
/* Validation check */
317-
if ((vma->vm_end - vma->vm_start) != ALIGN(cb->size, PAGE_SIZE)) {
318+
user_cb_size = vma->vm_end - vma->vm_start;
319+
if (user_cb_size != ALIGN(cb->size, PAGE_SIZE)) {
318320
dev_err(hdev->dev,
319321
"CB mmap failed, mmap size 0x%lx != 0x%x cb size\n",
320322
vma->vm_end - vma->vm_start, cb->size);
321323
rc = -EINVAL;
322324
goto put_cb;
323325
}
324326

327+
if (!access_ok((void __user *) (uintptr_t) vma->vm_start,
328+
user_cb_size)) {
329+
dev_err(hdev->dev,
330+
"user pointer is invalid - 0x%lx\n",
331+
vma->vm_start);
332+
333+
rc = -EINVAL;
334+
goto put_cb;
335+
}
336+
325337
spin_lock(&cb->lock);
326338

327339
if (cb->mmap) {

drivers/misc/habanalabs/common/command_submission.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,14 @@ static int cs_ioctl_signal_wait(struct hl_fpriv *hpriv, enum hl_cs_type cs_type,
808808

809809
/* currently it is guaranteed to have only one chunk */
810810
chunk = &cs_chunk_array[0];
811+
812+
if (chunk->queue_index >= hdev->asic_prop.max_queues) {
813+
dev_err(hdev->dev, "Queue index %d is invalid\n",
814+
chunk->queue_index);
815+
rc = -EINVAL;
816+
goto free_cs_chunk_array;
817+
}
818+
811819
q_idx = chunk->queue_index;
812820
hw_queue_prop = &hdev->asic_prop.hw_queues_props[q_idx];
813821
q_type = hw_queue_prop->type;

drivers/misc/habanalabs/common/debugfs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
static struct dentry *hl_debug_root;
2020

2121
static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
22-
u8 i2c_reg, u32 *val)
22+
u8 i2c_reg, long *val)
2323
{
2424
struct armcp_packet pkt;
2525
int rc;
@@ -36,7 +36,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,
3636
pkt.i2c_reg = i2c_reg;
3737

3838
rc = hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, sizeof(pkt),
39-
0, (long *) val);
39+
0, val);
4040

4141
if (rc)
4242
dev_err(hdev->dev, "Failed to read from I2C, error %d\n", rc);
@@ -827,7 +827,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
827827
struct hl_dbg_device_entry *entry = file_inode(f)->i_private;
828828
struct hl_device *hdev = entry->hdev;
829829
char tmp_buf[32];
830-
u32 val;
830+
long val;
831831
ssize_t rc;
832832

833833
if (*ppos)
@@ -842,7 +842,7 @@ static ssize_t hl_i2c_data_read(struct file *f, char __user *buf,
842842
return rc;
843843
}
844844

845-
sprintf(tmp_buf, "0x%02x\n", val);
845+
sprintf(tmp_buf, "0x%02lx\n", val);
846846
rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
847847
strlen(tmp_buf));
848848

0 commit comments

Comments
 (0)