Skip to content

Commit dca4f5f

Browse files
GustavoARSilvaHans Verkuil
authored andcommitted
media: usb: pwc-uncompress: Use struct_size() helper in pwc_decompress()
Make use of the struct_size() helper instead of an open-coded version, in order to avoid any potential type mistakes or integer overflows that, in the worst scenario, could lead to heap overflows. Also, address the following sparse warnings: drivers/media/usb/pwc/pwc-uncompress.c:44:44: warning: using sizeof on a flexible structure Link: KSPP/linux#174 Signed-off-by: Gustavo A. R. Silva <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Hans Verkuil <[email protected]>
1 parent 4f03d53 commit dca4f5f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/media/usb/pwc/pwc-uncompress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ int pwc_decompress(struct pwc_device *pdev, struct pwc_frame_buf *fbuf)
4141
memcpy(raw_frame->cmd, pdev->cmd_buf, 4);
4242
memcpy(raw_frame+1, yuv, pdev->frame_size);
4343
vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0,
44-
pdev->frame_size + sizeof(struct pwc_raw_frame));
44+
struct_size(raw_frame, rawframe, pdev->frame_size));
4545
return 0;
4646
}
4747

0 commit comments

Comments
 (0)