diff mbox series

remoteproc: qcom: fix sparse warnings

Message ID 1675180866-16695-1-git-send-email-quic_mojha@quicinc.com (mailing list archive)
State Accepted
Headers show
Series remoteproc: qcom: fix sparse warnings | expand

Commit Message

Mukesh Ojha Jan. 31, 2023, 4:01 p.m. UTC
This patch try to address below sparse warnings.

drivers/remoteproc/qcom_common.c:126:27: warning: restricted __le32 degrades to integer
drivers/remoteproc/qcom_common.c:133:32: warning: cast to restricted __le32
drivers/remoteproc/qcom_common.c:133:32: warning: cast from restricted __le64

Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/remoteproc/qcom_common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Mukesh Ojha Feb. 12, 2023, 4:11 p.m. UTC | #1
Friendly reminder.

-Mukesh

On 1/31/2023 9:31 PM, Mukesh Ojha wrote:
> This patch try to address below sparse warnings.
> 
> drivers/remoteproc/qcom_common.c:126:27: warning: restricted __le32 degrades to integer
> drivers/remoteproc/qcom_common.c:133:32: warning: cast to restricted __le32
> drivers/remoteproc/qcom_common.c:133:32: warning: cast from restricted __le64
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>   drivers/remoteproc/qcom_common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
> index 020349f..7133c1f 100644
> --- a/drivers/remoteproc/qcom_common.c
> +++ b/drivers/remoteproc/qcom_common.c
> @@ -123,14 +123,14 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
>   
>   	for (i = 0; i < seg_cnt; i++) {
>   		memcpy_fromio(&region, ptr + i, sizeof(region));
> -		if (region.valid == MD_REGION_VALID) {
> +		if (le32_to_cpu(region.valid) == MD_REGION_VALID) {
>   			name = kstrdup(region.name, GFP_KERNEL);
>   			if (!name) {
>   				iounmap(ptr);
>   				return -ENOMEM;
>   			}
>   			da = le64_to_cpu(region.address);
> -			size = le32_to_cpu(region.size);
> +			size = le64_to_cpu(region.size);
>   			rproc_coredump_add_custom_segment(rproc, da, size, NULL, name);
>   		}
>   	}
Dmitry Baryshkov Feb. 13, 2023, 12:55 a.m. UTC | #2
On 31/01/2023 18:01, Mukesh Ojha wrote:
> This patch try to address below sparse warnings.
> 
> drivers/remoteproc/qcom_common.c:126:27: warning: restricted __le32 degrades to integer
> drivers/remoteproc/qcom_common.c:133:32: warning: cast to restricted __le32
> drivers/remoteproc/qcom_common.c:133:32: warning: cast from restricted __le64
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

Also see below.

> ---
>   drivers/remoteproc/qcom_common.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
> index 020349f..7133c1f 100644
> --- a/drivers/remoteproc/qcom_common.c
> +++ b/drivers/remoteproc/qcom_common.c
> @@ -123,14 +123,14 @@ static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
>   
>   	for (i = 0; i < seg_cnt; i++) {
>   		memcpy_fromio(&region, ptr + i, sizeof(region));
> -		if (region.valid == MD_REGION_VALID) {
> +		if (le32_to_cpu(region.valid) == MD_REGION_VALID) {
>   			name = kstrdup(region.name, GFP_KERNEL);

While you are at it, please replace this kstrdup() with kstrndup(). 
There is no guarantee that region.name will be 0-terminated.

>   			if (!name) {
>   				iounmap(ptr);
>   				return -ENOMEM;
>   			}
>   			da = le64_to_cpu(region.address);
> -			size = le32_to_cpu(region.size);
> +			size = le64_to_cpu(region.size);
>   			rproc_coredump_add_custom_segment(rproc, da, size, NULL, name);
>   		}
>   	}
Mukesh Ojha Feb. 14, 2023, 2:12 p.m. UTC | #3
On 2/13/2023 6:25 AM, Dmitry Baryshkov wrote:
> On 31/01/2023 18:01, Mukesh Ojha wrote:
>> This patch try to address below sparse warnings.
>>
>> drivers/remoteproc/qcom_common.c:126:27: warning: restricted __le32 
>> degrades to integer
>> drivers/remoteproc/qcom_common.c:133:32: warning: cast to restricted 
>> __le32
>> drivers/remoteproc/qcom_common.c:133:32: warning: cast from restricted 
>> __le64
>>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 

Thanks for the review.

> Also see below.
> 
>> ---
>>   drivers/remoteproc/qcom_common.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/remoteproc/qcom_common.c 
>> b/drivers/remoteproc/qcom_common.c
>> index 020349f..7133c1f 100644
>> --- a/drivers/remoteproc/qcom_common.c
>> +++ b/drivers/remoteproc/qcom_common.c
>> @@ -123,14 +123,14 @@ static int qcom_add_minidump_segments(struct 
>> rproc *rproc, struct minidump_subsy
>>       for (i = 0; i < seg_cnt; i++) {
>>           memcpy_fromio(&region, ptr + i, sizeof(region));
>> -        if (region.valid == MD_REGION_VALID) {
>> +        if (le32_to_cpu(region.valid) == MD_REGION_VALID) {
>>               name = kstrdup(region.name, GFP_KERNEL);
> 
> While you are at it, please replace this kstrdup() with kstrndup(). 
> There is no guarantee that region.name will be 0-terminated.

Kept it as separate patch in this mail thread itself.

-Mukesh
>>               if (!name) {
>>                   iounmap(ptr);
>>                   return -ENOMEM;
>>               }
>>               da = le64_to_cpu(region.address);
>> -            size = le32_to_cpu(region.size);
>> +            size = le64_to_cpu(region.size);
>>               rproc_coredump_add_custom_segment(rproc, da, size, NULL, 
>> name);
>>           }
>>       }
>
diff mbox series

Patch

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 020349f..7133c1f 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -123,14 +123,14 @@  static int qcom_add_minidump_segments(struct rproc *rproc, struct minidump_subsy
 
 	for (i = 0; i < seg_cnt; i++) {
 		memcpy_fromio(&region, ptr + i, sizeof(region));
-		if (region.valid == MD_REGION_VALID) {
+		if (le32_to_cpu(region.valid) == MD_REGION_VALID) {
 			name = kstrdup(region.name, GFP_KERNEL);
 			if (!name) {
 				iounmap(ptr);
 				return -ENOMEM;
 			}
 			da = le64_to_cpu(region.address);
-			size = le32_to_cpu(region.size);
+			size = le64_to_cpu(region.size);
 			rproc_coredump_add_custom_segment(rproc, da, size, NULL, name);
 		}
 	}