Thermal/int340x: avoid unnecessary pointer casting
PATCH 1/1 Thermal/int340x: avoid unnecessary pointer casting
Avoid pointer casting which may also lead to problems on big endian 64 bit systems.
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Jacob Pan <[email protected]>
--- drivers/thermal/int340x_thermal/acpi_thermal_rel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/thermal/int340x_thermal/acpi_thermal_rel.c +5 -5
@@ -317,21 +317,21 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd, {int ret =0 ;unsigned long length =0 ; -unsigned long count =0 ; +int count =0 ;char __user *arg = (void __user *)__arg;struct trt *trts;struct art *arts;switch (cmd) {case ACPI_THERMAL_GET_TRT_COUNT : - ret =acpi_parse_trt (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_trt (acpi_thermal_rel_handle, &count, &trts, false);kfree (trts);if (!ret)return put_user (count, (unsigned long __user *)__arg);return ret;case ACPI_THERMAL_GET_TRT_LEN : - ret =acpi_parse_trt (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_trt (acpi_thermal_rel_handle, &count, &trts, false);kfree (trts); length = count *sizeof (union trt_object );
@@ -341,14 +341,14 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd,case ACPI_THERMAL_GET_TRT :return fill_trt (arg);case ACPI_THERMAL_GET_ART_COUNT : - ret =acpi_parse_art (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_art (acpi_thermal_rel_handle, &count, &arts, false);kfree (arts);if (!ret)return put_user (count, (unsigned long __user *)__arg);return ret;case ACPI_THERMAL_GET_ART_LEN : - ret =acpi_parse_art (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_art (acpi_thermal_rel_handle, &count, &arts, false);kfree (arts); length = count *sizeof (union art_object );
Signature · 1 line
1.9.1
Hello,
Quoted 45 lines · Jacob Pan
Avoid pointer casting which may also lead to problems on big endian 64 bit systems.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Jacob Pan <[email protected]>--- drivers/thermal/int340x_thermal/acpi_thermal_rel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/thermal/int340x_thermal/acpi_thermal_rel.c +4
-4@@ -317,21 +317,21 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd, {int ret =0 ;unsigned long length =0 ; -unsigned long count =0 ; +int count =0 ;char __user *arg = (void __user *)__arg;struct trt *trts;struct art *arts;switch (cmd) {case ACPI_THERMAL_GET_TRT_COUNT : - ret =acpi_parse_trt (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_trt (acpi_thermal_rel_handle, &count, &trts, false);kfree (trts);if (!ret)return put_user (count, (unsigned long __user *)__arg);return ret;case ACPI_THERMAL_GET_TRT_LEN : - ret =acpi_parse_trt (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_trt (acpi_thermal_rel_handle, &count, &trts, false);kfree (trts); length = count *sizeof (union trt_object );@@ -341,14 +341,14 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd,case ACPI_THERMAL_GET_TRT :return fill_trt (arg);case ACPI_THERMAL_GET_ART_COUNT : - ret =acpi_parse_art (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_art (acpi_thermal_rel_handle, &count, &arts, false);
drivers/thermal/int340x_thermal/acpi_thermal_rel.c static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd, · line 354
Quoted 10 lines
drivers/thermal/int340x_thermal/acpi_thermal_rel.c +1
-1kfree (arts);if (!ret)return put_user (count, (unsigned long __user *)__arg);return ret;case ACPI_THERMAL_GET_ART_LEN : - ret =acpi_parse_art (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_art (acpi_thermal_rel_handle, &count, &arts, false);kfree (arts); length = count *sizeof (union art_object );
To me, this change is reasonable.
Rui, any comments/objections on this fix?
Quoted 7 lines
Signature · 6 lines
1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Zhang Rui
reviewerQuoted 5 lines · Jacob Pan
Avoid pointer casting which may also lead to problems on big endian 64 bit systems.
Reported-by Dan Carpenter <[email protected]>Signed-off-by Jacob Pan <[email protected]>
Patch queued for 3.19.
thanks,
rui
Quoted 50 lines
--- drivers/thermal/int340x_thermal/acpi_thermal_rel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/thermal/int340x_thermal/acpi_thermal_rel.c +5
-5@@ -317,21 +317,21 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd, {int ret =0 ;unsigned long length =0 ; -unsigned long count =0 ; +int count =0 ;char __user *arg = (void __user *)__arg;struct trt *trts;struct art *arts;switch (cmd) {case ACPI_THERMAL_GET_TRT_COUNT : - ret =acpi_parse_trt (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_trt (acpi_thermal_rel_handle, &count, &trts, false);kfree (trts);if (!ret)return put_user (count, (unsigned long __user *)__arg);return ret;case ACPI_THERMAL_GET_TRT_LEN : - ret =acpi_parse_trt (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_trt (acpi_thermal_rel_handle, &count, &trts, false);kfree (trts); length = count *sizeof (union trt_object );@@ -341,14 +341,14 @@ static long acpi_thermal_rel_ioctl(struct file *f, unsigned int cmd,case ACPI_THERMAL_GET_TRT :return fill_trt (arg);case ACPI_THERMAL_GET_ART_COUNT : - ret =acpi_parse_art (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_art (acpi_thermal_rel_handle, &count, &arts, false);kfree (arts);if (!ret)return put_user (count, (unsigned long __user *)__arg);return ret;case ACPI_THERMAL_GET_ART_LEN : - ret =acpi_parse_art (acpi_thermal_rel_handle, (int *)&count, + ret =acpi_parse_art (acpi_thermal_rel_handle, &count, &arts, false);kfree (arts); length = count *sizeof (union art_object );