Skip to content

Commit 30a3f2f

Browse files
nicolincjoergroedel
authored andcommitted
iommu: Fix two issues in iommu_copy_struct_from_user()
In the review for iommu_copy_struct_to_user() helper, Matt pointed out that a NULL pointer should be rejected prior to dereferencing it: https://lore.kernel.org/all/[email protected] And Alok pointed out a typo at the same time: https://lore.kernel.org/all/[email protected] Since both issues were copied from iommu_copy_struct_from_user(), fix them first in the current header. Fixes: e9d36c0 ("iommu: Add iommu_copy_struct_from_user helper") Cc: [email protected] Signed-off-by: Nicolin Chen <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Acked-by: Alok Tiwari <[email protected]> Reviewed-by: Matthew R. Ochs <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 8dee308 commit 30a3f2f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

include/linux/iommu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ static inline int __iommu_copy_struct_from_user(
440440
void *dst_data, const struct iommu_user_data *src_data,
441441
unsigned int data_type, size_t data_len, size_t min_len)
442442
{
443-
if (src_data->type != data_type)
444-
return -EINVAL;
445443
if (WARN_ON(!dst_data || !src_data))
446444
return -EINVAL;
445+
if (src_data->type != data_type)
446+
return -EINVAL;
447447
if (src_data->len < min_len || data_len < src_data->len)
448448
return -EINVAL;
449449
return copy_struct_from_user(dst_data, data_len, src_data->uptr,
@@ -456,8 +456,8 @@ static inline int __iommu_copy_struct_from_user(
456456
* include/uapi/linux/iommufd.h
457457
* @user_data: Pointer to a struct iommu_user_data for user space data info
458458
* @data_type: The data type of the @kdst. Must match with @user_data->type
459-
* @min_last: The last memember of the data structure @kdst points in the
460-
* initial version.
459+
* @min_last: The last member of the data structure @kdst points in the initial
460+
* version.
461461
* Return 0 for success, otherwise -error.
462462
*/
463463
#define iommu_copy_struct_from_user(kdst, user_data, data_type, min_last) \

0 commit comments

Comments
 (0)