2022-06-08 12:31:44

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH net-next v1 0/5] ptp_ocp: set of small cleanups

The set of (independent) cleanups against ptp_ocp driver.
Each patch has its own description, no need to repeat it here.

Andy Shevchenko (5):
ptp_ocp: use dev_err_probe()
ptp_ocp: use bits.h macros for all masks
ptp_ocp: drop duplicate NULL check in ptp_ocp_detach()
ptp_ocp: do not call pci_set_drvdata(pdev, NULL)
ptp_ocp: replace kzalloc(x*y) by kcalloc(y, x)

drivers/ptp/ptp_ocp.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)

--
2.35.1


2022-06-08 12:31:50

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 net-next 5/5] ptp_ocp: replace kzalloc(x*y) by kcalloc(y, x)

While here it may be no difference, the kcalloc() has some checks
against overflow and it's logically correct to call it for an array.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/ptp/ptp_ocp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
index 857e35c68a04..83da36e69361 100644
--- a/drivers/ptp/ptp_ocp.c
+++ b/drivers/ptp/ptp_ocp.c
@@ -2155,7 +2155,7 @@ ptp_ocp_fb_set_pins(struct ptp_ocp *bp)
struct ptp_pin_desc *config;
int i;

- config = kzalloc(sizeof(*config) * 4, GFP_KERNEL);
+ config = kcalloc(4, sizeof(*config), GFP_KERNEL);
if (!config)
return -ENOMEM;

--
2.35.1

2022-06-08 22:16:03

by Vadim Fedorenko

[permalink] [raw]
Subject: Re: [PATCH v1 net-next 5/5] ptp_ocp: replace kzalloc(x*y) by kcalloc(y, x)

On 08.06.2022 13:03, Andy Shevchenko wrote:
> While here it may be no difference, the kcalloc() has some checks
> against overflow and it's logically correct to call it for an array.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Acked-by: Vadim Fedorenko <[email protected]>

> ---
> drivers/ptp/ptp_ocp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 857e35c68a04..83da36e69361 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -2155,7 +2155,7 @@ ptp_ocp_fb_set_pins(struct ptp_ocp *bp)
> struct ptp_pin_desc *config;
> int i;
>
> - config = kzalloc(sizeof(*config) * 4, GFP_KERNEL);
> + config = kcalloc(4, sizeof(*config), GFP_KERNEL);
> if (!config)
> return -ENOMEM;
>