]> xenbits.xensource.com Git - people/aperard/linux.git/commitdiff
media: pvrusb2: fix pvr2_stream_callback casts
authorArnd Bergmann <arnd@arndb.de>
Tue, 13 Feb 2024 10:04:27 +0000 (11:04 +0100)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:20:49 +0000 (18:20 -0400)
[ Upstream commit 30baa4a96b23add91a87305baaeba82c4e109e1f ]

clang-16 complains about a control flow integrity (KCFI) issue in pvrusb2,
which casts three different prototypes into pvr2_stream_callback:

drivers/media/usb/pvrusb2/pvrusb2-v4l2.c:1070:30: error: cast from 'void (*)(struct pvr2_v4l2_fh *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
 1070 |         pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/usb/pvrusb2/pvrusb2-context.c:110:6: error: cast from 'void (*)(struct pvr2_context *)' to 'void (*)(void *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  110 |                                         (void (*)(void *))pvr2_context_notify,
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/media/usb/pvrusb2/pvrusb2-dvb.c:152:6: error: cast from 'void (*)(struct pvr2_dvb_adapter *)' to 'pvr2_stream_callback' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  152 |                                  (pvr2_stream_callback) pvr2_dvb_notify, adap);
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change the functions to actually take a void* argument so the cast is no longer
needed.

Fixes: bb8ce9d9143c ("V4L/DVB (7682): pvrusb2-dvb: finish up stream & buffer handling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/pvrusb2/pvrusb2-context.c
drivers/media/usb/pvrusb2/pvrusb2-dvb.c
drivers/media/usb/pvrusb2/pvrusb2-v4l2.c

index 1764674de98bc062faf5861681690aa19586e1ed..58f2f3ff10ee226a327722930f9ced939362e543 100644 (file)
@@ -90,8 +90,10 @@ static void pvr2_context_destroy(struct pvr2_context *mp)
 }
 
 
-static void pvr2_context_notify(struct pvr2_context *mp)
+static void pvr2_context_notify(void *ptr)
 {
+       struct pvr2_context *mp = ptr;
+
        pvr2_context_set_notify(mp,!0);
 }
 
@@ -106,9 +108,7 @@ static void pvr2_context_check(struct pvr2_context *mp)
                pvr2_trace(PVR2_TRACE_CTXT,
                           "pvr2_context %p (initialize)", mp);
                /* Finish hardware initialization */
-               if (pvr2_hdw_initialize(mp->hdw,
-                                       (void (*)(void *))pvr2_context_notify,
-                                       mp)) {
+               if (pvr2_hdw_initialize(mp->hdw, pvr2_context_notify, mp)) {
                        mp->video_stream.stream =
                                pvr2_hdw_get_video_stream(mp->hdw);
                        /* Trigger interface initialization.  By doing this
index 26811efe0fb58b32dbfe05c63cb1380e3704aa5c..9a9bae21c61475e9a5a8a98e68a8fb842188d6bc 100644 (file)
@@ -88,8 +88,10 @@ static int pvr2_dvb_feed_thread(void *data)
        return stat;
 }
 
-static void pvr2_dvb_notify(struct pvr2_dvb_adapter *adap)
+static void pvr2_dvb_notify(void *ptr)
 {
+       struct pvr2_dvb_adapter *adap = ptr;
+
        wake_up(&adap->buffer_wait_data);
 }
 
@@ -149,7 +151,7 @@ static int pvr2_dvb_stream_do_start(struct pvr2_dvb_adapter *adap)
        }
 
        pvr2_stream_set_callback(pvr->video_stream.stream,
-                                (pvr2_stream_callback) pvr2_dvb_notify, adap);
+                                pvr2_dvb_notify, adap);
 
        ret = pvr2_stream_set_buffer_count(stream, PVR2_DVB_BUFFER_COUNT);
        if (ret < 0) return ret;
index d195bd6a2248b93952cc85446aa5c316ac5e7e48..d608b793fa847b72c19ea78b4250283b9bf05f4b 100644 (file)
@@ -1033,8 +1033,10 @@ static int pvr2_v4l2_open(struct file *file)
 }
 
 
-static void pvr2_v4l2_notify(struct pvr2_v4l2_fh *fhp)
+static void pvr2_v4l2_notify(void *ptr)
 {
+       struct pvr2_v4l2_fh *fhp = ptr;
+
        wake_up(&fhp->wait_data);
 }
 
@@ -1067,7 +1069,7 @@ static int pvr2_v4l2_iosetup(struct pvr2_v4l2_fh *fh)
 
        hdw = fh->channel.mc_head->hdw;
        sp = fh->pdi->stream->stream;
-       pvr2_stream_set_callback(sp,(pvr2_stream_callback)pvr2_v4l2_notify,fh);
+       pvr2_stream_set_callback(sp, pvr2_v4l2_notify, fh);
        pvr2_hdw_set_stream_type(hdw,fh->pdi->config);
        if ((ret = pvr2_hdw_set_streaming(hdw,!0)) < 0) return ret;
        return pvr2_ioread_set_enabled(fh->rhp,!0);