Skip to content

Commit 1c353dc

Browse files
committed
Merge tag 'media/v6.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab: - honour privacy led with pdx86/int3472 - fix invalid file access on cx18 and ivtv - forbid remove_bufs when legacy fileio is active on videbuf2 - add an heuristic to find stream entity on uvcvideo * tag 'media/v6.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: media: videobuf2: forbid remove_bufs when legacy fileio is active media: uvcvideo: Use heuristic to find stream entity media: v4l2-subdev / pdx86: int3472: Use "privacy" as con_id for the privacy LED media: ivtv: Fix invalid access to file * media: cx18: Fix invalid access to file *
2 parents 284922f + 27afd6e commit 1c353dc

File tree

10 files changed

+73
-37
lines changed

10 files changed

+73
-37
lines changed

drivers/media/common/videobuf2/videobuf2-v4l2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,11 @@ int vb2_ioctl_remove_bufs(struct file *file, void *priv,
10101010
if (vb2_queue_is_busy(vdev->queue, file))
10111011
return -EBUSY;
10121012

1013+
if (vb2_fileio_is_active(vdev->queue)) {
1014+
dprintk(vdev->queue, 1, "file io in progress\n");
1015+
return -EBUSY;
1016+
}
1017+
10131018
return vb2_core_remove_bufs(vdev->queue, d->index, d->count);
10141019
}
10151020
EXPORT_SYMBOL_GPL(vb2_ioctl_remove_bufs);

drivers/media/pci/cx18/cx18-driver.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,11 +1136,8 @@ int cx18_init_on_first_open(struct cx18 *cx)
11361136
int video_input;
11371137
int fw_retry_count = 3;
11381138
struct v4l2_frequency vf;
1139-
struct cx18_open_id fh;
11401139
v4l2_std_id std;
11411140

1142-
fh.cx = cx;
1143-
11441141
if (test_bit(CX18_F_I_FAILED, &cx->i_flags))
11451142
return -ENXIO;
11461143

@@ -1220,14 +1217,14 @@ int cx18_init_on_first_open(struct cx18 *cx)
12201217

12211218
video_input = cx->active_input;
12221219
cx->active_input++; /* Force update of input */
1223-
cx18_s_input(NULL, &fh, video_input);
1220+
cx18_do_s_input(cx, video_input);
12241221

12251222
/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
12261223
in one place. */
12271224
cx->std++; /* Force full standard initialization */
12281225
std = (cx->tuner_std == V4L2_STD_ALL) ? V4L2_STD_NTSC_M : cx->tuner_std;
1229-
cx18_s_std(NULL, &fh, std);
1230-
cx18_s_frequency(NULL, &fh, &vf);
1226+
cx18_do_s_std(cx, std);
1227+
cx18_do_s_frequency(cx, &vf);
12311228
return 0;
12321229
}
12331230

drivers/media/pci/cx18/cx18-ioctl.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,8 @@ static int cx18_g_input(struct file *file, void *fh, unsigned int *i)
521521
return 0;
522522
}
523523

524-
int cx18_s_input(struct file *file, void *fh, unsigned int inp)
524+
int cx18_do_s_input(struct cx18 *cx, unsigned int inp)
525525
{
526-
struct cx18_open_id *id = file2id(file);
527-
struct cx18 *cx = id->cx;
528526
v4l2_std_id std = V4L2_STD_ALL;
529527
const struct cx18_card_video_input *card_input =
530528
cx->card->video_inputs + inp;
@@ -558,6 +556,11 @@ int cx18_s_input(struct file *file, void *fh, unsigned int inp)
558556
return 0;
559557
}
560558

559+
static int cx18_s_input(struct file *file, void *fh, unsigned int inp)
560+
{
561+
return cx18_do_s_input(file2id(file)->cx, inp);
562+
}
563+
561564
static int cx18_g_frequency(struct file *file, void *fh,
562565
struct v4l2_frequency *vf)
563566
{
@@ -570,11 +573,8 @@ static int cx18_g_frequency(struct file *file, void *fh,
570573
return 0;
571574
}
572575

573-
int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
576+
int cx18_do_s_frequency(struct cx18 *cx, const struct v4l2_frequency *vf)
574577
{
575-
struct cx18_open_id *id = file2id(file);
576-
struct cx18 *cx = id->cx;
577-
578578
if (vf->tuner != 0)
579579
return -EINVAL;
580580

@@ -585,6 +585,12 @@ int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *v
585585
return 0;
586586
}
587587

588+
static int cx18_s_frequency(struct file *file, void *fh,
589+
const struct v4l2_frequency *vf)
590+
{
591+
return cx18_do_s_frequency(file2id(file)->cx, vf);
592+
}
593+
588594
static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
589595
{
590596
struct cx18 *cx = file2id(file)->cx;
@@ -593,11 +599,8 @@ static int cx18_g_std(struct file *file, void *fh, v4l2_std_id *std)
593599
return 0;
594600
}
595601

596-
int cx18_s_std(struct file *file, void *fh, v4l2_std_id std)
602+
int cx18_do_s_std(struct cx18 *cx, v4l2_std_id std)
597603
{
598-
struct cx18_open_id *id = file2id(file);
599-
struct cx18 *cx = id->cx;
600-
601604
if ((std & V4L2_STD_ALL) == 0)
602605
return -EINVAL;
603606

@@ -642,6 +645,11 @@ int cx18_s_std(struct file *file, void *fh, v4l2_std_id std)
642645
return 0;
643646
}
644647

648+
static int cx18_s_std(struct file *file, void *fh, v4l2_std_id std)
649+
{
650+
return cx18_do_s_std(file2id(file)->cx, std);
651+
}
652+
645653
static int cx18_s_tuner(struct file *file, void *fh, const struct v4l2_tuner *vt)
646654
{
647655
struct cx18_open_id *id = file2id(file);

drivers/media/pci/cx18/cx18-ioctl.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ u16 cx18_service2vbi(int type);
1212
void cx18_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
1313
u16 cx18_get_service_set(struct v4l2_sliced_vbi_format *fmt);
1414
void cx18_set_funcs(struct video_device *vdev);
15-
int cx18_s_std(struct file *file, void *fh, v4l2_std_id std);
16-
int cx18_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf);
17-
int cx18_s_input(struct file *file, void *fh, unsigned int inp);
15+
16+
struct cx18;
17+
int cx18_do_s_std(struct cx18 *cx, v4l2_std_id std);
18+
int cx18_do_s_frequency(struct cx18 *cx, const struct v4l2_frequency *vf);
19+
int cx18_do_s_input(struct cx18 *cx, unsigned int inp);

drivers/media/pci/ivtv/ivtv-driver.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,15 +1247,12 @@ static int ivtv_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
12471247

12481248
int ivtv_init_on_first_open(struct ivtv *itv)
12491249
{
1250-
struct v4l2_frequency vf;
12511250
/* Needed to call ioctls later */
1252-
struct ivtv_open_id fh;
1251+
struct ivtv_stream *s = &itv->streams[IVTV_ENC_STREAM_TYPE_MPG];
1252+
struct v4l2_frequency vf;
12531253
int fw_retry_count = 3;
12541254
int video_input;
12551255

1256-
fh.itv = itv;
1257-
fh.type = IVTV_ENC_STREAM_TYPE_MPG;
1258-
12591256
if (test_bit(IVTV_F_I_FAILED, &itv->i_flags))
12601257
return -ENXIO;
12611258

@@ -1297,13 +1294,13 @@ int ivtv_init_on_first_open(struct ivtv *itv)
12971294

12981295
video_input = itv->active_input;
12991296
itv->active_input++; /* Force update of input */
1300-
ivtv_s_input(NULL, &fh, video_input);
1297+
ivtv_do_s_input(itv, video_input);
13011298

13021299
/* Let the VIDIOC_S_STD ioctl do all the work, keeps the code
13031300
in one place. */
13041301
itv->std++; /* Force full standard initialization */
13051302
itv->std_out = itv->std;
1306-
ivtv_s_frequency(NULL, &fh, &vf);
1303+
ivtv_do_s_frequency(s, &vf);
13071304

13081305
if (itv->card->v4l2_capabilities & V4L2_CAP_VIDEO_OUTPUT) {
13091306
/* Turn on the TV-out: ivtv_init_mpeg_decoder() initializes

drivers/media/pci/ivtv/ivtv-ioctl.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -974,9 +974,8 @@ static int ivtv_g_input(struct file *file, void *fh, unsigned int *i)
974974
return 0;
975975
}
976976

977-
int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
977+
int ivtv_do_s_input(struct ivtv *itv, unsigned int inp)
978978
{
979-
struct ivtv *itv = file2id(file)->itv;
980979
v4l2_std_id std;
981980
int i;
982981

@@ -1017,6 +1016,11 @@ int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
10171016
return 0;
10181017
}
10191018

1019+
static int ivtv_s_input(struct file *file, void *fh, unsigned int inp)
1020+
{
1021+
return ivtv_do_s_input(file2id(file)->itv, inp);
1022+
}
1023+
10201024
static int ivtv_g_output(struct file *file, void *fh, unsigned int *i)
10211025
{
10221026
struct ivtv *itv = file2id(file)->itv;
@@ -1065,10 +1069,9 @@ static int ivtv_g_frequency(struct file *file, void *fh, struct v4l2_frequency *
10651069
return 0;
10661070
}
10671071

1068-
int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf)
1072+
int ivtv_do_s_frequency(struct ivtv_stream *s, const struct v4l2_frequency *vf)
10691073
{
1070-
struct ivtv *itv = file2id(file)->itv;
1071-
struct ivtv_stream *s = &itv->streams[file2id(file)->type];
1074+
struct ivtv *itv = s->itv;
10721075

10731076
if (s->vdev.vfl_dir)
10741077
return -ENOTTY;
@@ -1082,6 +1085,15 @@ int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *v
10821085
return 0;
10831086
}
10841087

1088+
static int ivtv_s_frequency(struct file *file, void *fh,
1089+
const struct v4l2_frequency *vf)
1090+
{
1091+
struct ivtv_open_id *id = file2id(file);
1092+
struct ivtv *itv = id->itv;
1093+
1094+
return ivtv_do_s_frequency(&itv->streams[id->type], vf);
1095+
}
1096+
10851097
static int ivtv_g_std(struct file *file, void *fh, v4l2_std_id *std)
10861098
{
10871099
struct ivtv *itv = file2id(file)->itv;

drivers/media/pci/ivtv/ivtv-ioctl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#ifndef IVTV_IOCTL_H
1010
#define IVTV_IOCTL_H
1111

12+
struct ivtv;
13+
1214
u16 ivtv_service2vbi(int type);
1315
void ivtv_expand_service_set(struct v4l2_sliced_vbi_format *fmt, int is_pal);
1416
u16 ivtv_get_service_set(struct v4l2_sliced_vbi_format *fmt);
@@ -17,7 +19,7 @@ int ivtv_set_speed(struct ivtv *itv, int speed);
1719
void ivtv_set_funcs(struct video_device *vdev);
1820
void ivtv_s_std_enc(struct ivtv *itv, v4l2_std_id std);
1921
void ivtv_s_std_dec(struct ivtv *itv, v4l2_std_id std);
20-
int ivtv_s_frequency(struct file *file, void *fh, const struct v4l2_frequency *vf);
21-
int ivtv_s_input(struct file *file, void *fh, unsigned int inp);
22+
int ivtv_do_s_frequency(struct ivtv_stream *s, const struct v4l2_frequency *vf);
23+
int ivtv_do_s_input(struct ivtv *itv, unsigned int inp);
2224

2325
#endif

drivers/media/usb/uvc/uvc_driver.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,26 @@ static struct uvc_entity *uvc_entity_by_reference(struct uvc_device *dev,
167167

168168
static struct uvc_streaming *uvc_stream_by_id(struct uvc_device *dev, int id)
169169
{
170-
struct uvc_streaming *stream;
170+
struct uvc_streaming *stream, *last_stream;
171+
unsigned int count = 0;
171172

172173
list_for_each_entry(stream, &dev->streams, list) {
174+
count += 1;
175+
last_stream = stream;
173176
if (stream->header.bTerminalLink == id)
174177
return stream;
175178
}
176179

180+
/*
181+
* If the streaming entity is referenced by an invalid ID, notify the
182+
* user and use heuristics to guess the correct entity.
183+
*/
184+
if (count == 1 && id == UVC_INVALID_ENTITY_ID) {
185+
dev_warn(&dev->intf->dev,
186+
"UVC non compliance: Invalid USB header. The streaming entity has an invalid ID, guessing the correct one.");
187+
return last_stream;
188+
}
189+
177190
return NULL;
178191
}
179192

drivers/media/v4l2-core/v4l2-subdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2608,7 +2608,7 @@ EXPORT_SYMBOL_GPL(v4l2_subdev_is_streaming);
26082608
int v4l2_subdev_get_privacy_led(struct v4l2_subdev *sd)
26092609
{
26102610
#if IS_REACHABLE(CONFIG_LEDS_CLASS)
2611-
sd->privacy_led = led_get(sd->dev, "privacy-led");
2611+
sd->privacy_led = led_get(sd->dev, "privacy");
26122612
if (IS_ERR(sd->privacy_led) && PTR_ERR(sd->privacy_led) != -ENOENT)
26132613
return dev_err_probe(sd->dev, PTR_ERR(sd->privacy_led),
26142614
"getting privacy LED\n");

drivers/platform/x86/intel/int3472/led.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gp
4343

4444
int3472->pled.lookup.provider = int3472->pled.name;
4545
int3472->pled.lookup.dev_id = int3472->sensor_name;
46-
int3472->pled.lookup.con_id = "privacy-led";
46+
int3472->pled.lookup.con_id = "privacy";
4747
led_add_lookup(&int3472->pled.lookup);
4848

4949
return 0;

0 commit comments

Comments
 (0)