All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remoteproc: qcom: fix sparse warnings
@ 2023-01-31 16:01 Mukesh Ojha
  2023-02-12 16:11 ` Mukesh Ojha
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Mukesh Ojha @ 2023-01-31 16:01 UTC (permalink / raw)
  To: agross, andersson, mathieu.poirier, konrad.dybcio
  Cc: linux-arm-msm, linux-remoteproc, linux-kernel, Mukesh Ojha

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);
 		}
 	}
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] remoteproc: qcom: fix sparse warnings
  2023-01-31 16:01 [PATCH] remoteproc: qcom: fix sparse warnings Mukesh Ojha
@ 2023-02-12 16:11 ` Mukesh Ojha
  2023-02-13  0:55 ` Dmitry Baryshkov
  2023-02-14 14:08 ` [PATCH] remoteproc: qcom: replace kstrdup with kstrndup Mukesh Ojha
  2 siblings, 0 replies; 8+ messages in thread
From: Mukesh Ojha @ 2023-02-12 16:11 UTC (permalink / raw)
  To: agross, andersson, mathieu.poirier, konrad.dybcio
  Cc: linux-arm-msm, linux-remoteproc, linux-kernel

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);
>   		}
>   	}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] remoteproc: qcom: fix sparse warnings
  2023-01-31 16:01 [PATCH] remoteproc: qcom: fix sparse warnings Mukesh Ojha
  2023-02-12 16:11 ` Mukesh Ojha
@ 2023-02-13  0:55 ` Dmitry Baryshkov
  2023-02-14 14:12   ` Mukesh Ojha
  2023-02-14 14:08 ` [PATCH] remoteproc: qcom: replace kstrdup with kstrndup Mukesh Ojha
  2 siblings, 1 reply; 8+ messages in thread
From: Dmitry Baryshkov @ 2023-02-13  0:55 UTC (permalink / raw)
  To: Mukesh Ojha, agross, andersson, mathieu.poirier, konrad.dybcio
  Cc: linux-arm-msm, linux-remoteproc, linux-kernel

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);
>   		}
>   	}

-- 
With best wishes
Dmitry


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH] remoteproc: qcom: replace kstrdup with kstrndup
  2023-01-31 16:01 [PATCH] remoteproc: qcom: fix sparse warnings Mukesh Ojha
  2023-02-12 16:11 ` Mukesh Ojha
  2023-02-13  0:55 ` Dmitry Baryshkov
@ 2023-02-14 14:08 ` Mukesh Ojha
  2023-02-14 16:39   ` Bjorn Andersson
  2023-02-14 17:30   ` Bjorn Andersson
  2 siblings, 2 replies; 8+ messages in thread
From: Mukesh Ojha @ 2023-02-14 14:08 UTC (permalink / raw)
  To: dmitry.baryshkov, agross, mathieu.poirier, konrad.dybcio
  Cc: linux-arm-msm, linux-remoteproc, linux-kernel, Mukesh Ojha

Since, there is no guarantee that region.name will be 0-terminated
from the firmware side, replace kstrdup with kstrndup.

Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
---
 drivers/remoteproc/qcom_common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index 020349f..7810f91 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -124,7 +124,7 @@ 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) {
-			name = kstrdup(region.name, GFP_KERNEL);
+			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
 			if (!name) {
 				iounmap(ptr);
 				return -ENOMEM;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] remoteproc: qcom: fix sparse warnings
  2023-02-13  0:55 ` Dmitry Baryshkov
@ 2023-02-14 14:12   ` Mukesh Ojha
  0 siblings, 0 replies; 8+ messages in thread
From: Mukesh Ojha @ 2023-02-14 14:12 UTC (permalink / raw)
  To: Dmitry Baryshkov, agross, andersson, mathieu.poirier, konrad.dybcio
  Cc: linux-arm-msm, linux-remoteproc, linux-kernel



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);
>>           }
>>       }
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] remoteproc: qcom: replace kstrdup with kstrndup
  2023-02-14 14:08 ` [PATCH] remoteproc: qcom: replace kstrdup with kstrndup Mukesh Ojha
@ 2023-02-14 16:39   ` Bjorn Andersson
  2023-02-15  5:16     ` Mukesh Ojha
  2023-02-14 17:30   ` Bjorn Andersson
  1 sibling, 1 reply; 8+ messages in thread
From: Bjorn Andersson @ 2023-02-14 16:39 UTC (permalink / raw)
  To: Mukesh Ojha
  Cc: dmitry.baryshkov, agross, mathieu.poirier, konrad.dybcio,
	linux-arm-msm, linux-remoteproc, linux-kernel

On Tue, Feb 14, 2023 at 07:38:11PM +0530, Mukesh Ojha wrote:
> Since, there is no guarantee that region.name will be 0-terminated
> from the firmware side, replace kstrdup with kstrndup.
> 
> Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>

Please don't send additional patches in-reply-to another patch, it makes
it impossible to use b4 to pick up the first patch.

And please don't send two patches which clearly will conflict with
each other. Now I had to manually apply the first patch...

Regards,
Bjorn

> ---
>  drivers/remoteproc/qcom_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
> index 020349f..7810f91 100644
> --- a/drivers/remoteproc/qcom_common.c
> +++ b/drivers/remoteproc/qcom_common.c
> @@ -124,7 +124,7 @@ 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) {
> -			name = kstrdup(region.name, GFP_KERNEL);
> +			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
>  			if (!name) {
>  				iounmap(ptr);
>  				return -ENOMEM;
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] remoteproc: qcom: replace kstrdup with kstrndup
  2023-02-14 14:08 ` [PATCH] remoteproc: qcom: replace kstrdup with kstrndup Mukesh Ojha
  2023-02-14 16:39   ` Bjorn Andersson
@ 2023-02-14 17:30   ` Bjorn Andersson
  1 sibling, 0 replies; 8+ messages in thread
From: Bjorn Andersson @ 2023-02-14 17:30 UTC (permalink / raw)
  To: mathieu.poirier, Mukesh Ojha, dmitry.baryshkov, agross, konrad.dybcio
  Cc: linux-kernel, linux-arm-msm, linux-remoteproc

On Tue, 14 Feb 2023 19:38:11 +0530, Mukesh Ojha wrote:
> Since, there is no guarantee that region.name will be 0-terminated
> from the firmware side, replace kstrdup with kstrndup.
> 
> 

Applied, thanks!

[1/1] remoteproc: qcom: replace kstrdup with kstrndup
      commit: 9d5b9ad97f83b2390a6006eeb5ae5e48ec4298ce

Best regards,
-- 
Bjorn Andersson <andersson@kernel.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] remoteproc: qcom: replace kstrdup with kstrndup
  2023-02-14 16:39   ` Bjorn Andersson
@ 2023-02-15  5:16     ` Mukesh Ojha
  0 siblings, 0 replies; 8+ messages in thread
From: Mukesh Ojha @ 2023-02-15  5:16 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: dmitry.baryshkov, agross, mathieu.poirier, konrad.dybcio,
	linux-arm-msm, linux-remoteproc, linux-kernel



On 2/14/2023 10:09 PM, Bjorn Andersson wrote:
> On Tue, Feb 14, 2023 at 07:38:11PM +0530, Mukesh Ojha wrote:
>> Since, there is no guarantee that region.name will be 0-terminated
>> from the firmware side, replace kstrdup with kstrndup.
>>
>> Suggested-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> 
> Please don't send additional patches in-reply-to another patch, it makes
> it impossible to use b4 to pick up the first patch.
> 
> And please don't send two patches which clearly will conflict with
> each other. Now I had to manually apply the first patch...
> 

Really sorry, for the inconvenience.
will keep in mind.

Thanks,
-Mukesh

> Regards,
> Bjorn
> 
>> ---
>>   drivers/remoteproc/qcom_common.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
>> index 020349f..7810f91 100644
>> --- a/drivers/remoteproc/qcom_common.c
>> +++ b/drivers/remoteproc/qcom_common.c
>> @@ -124,7 +124,7 @@ 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) {
>> -			name = kstrdup(region.name, GFP_KERNEL);
>> +			name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL);
>>   			if (!name) {
>>   				iounmap(ptr);
>>   				return -ENOMEM;
>> -- 
>> 2.7.4
>>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-02-15  5:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 16:01 [PATCH] remoteproc: qcom: fix sparse warnings Mukesh Ojha
2023-02-12 16:11 ` Mukesh Ojha
2023-02-13  0:55 ` Dmitry Baryshkov
2023-02-14 14:12   ` Mukesh Ojha
2023-02-14 14:08 ` [PATCH] remoteproc: qcom: replace kstrdup with kstrndup Mukesh Ojha
2023-02-14 16:39   ` Bjorn Andersson
2023-02-15  5:16     ` Mukesh Ojha
2023-02-14 17:30   ` Bjorn Andersson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.