[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <F29B73FA-2686-4244-8A93-84DFEEB7FDA2@mellanox.com>
Date: Sun, 19 Feb 2017 17:09:03 +0000
From: Majd Dibbiny <majd@...lanox.com>
To: SF Markus Elfring <elfring@...rs.sourceforge.net>
CC: "linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
Doug Ledford <dledford@...hat.com>,
Hal Rosenstock <hal.rosenstock@...il.com>,
"Leon Romanovsky" <leonro@...lanox.com>,
Matan Barak <matanb@...lanox.com>,
"Sean Hefty" <sean.hefty@...el.com>,
Yishai Hadas <yishaih@...lanox.com>,
LKML <linux-kernel@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: Re: [PATCH 07/29] IB/mlx4: Split a condition check in
handle_slaves_guid_change()
> On Feb 18, 2017, at 10:55 PM, SF Markus Elfring <elfring@...rs.sourceforge.net> wrote:
>
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Fri, 17 Feb 2017 21:41:25 +0100
>
> The kfree() function was called in up to two cases by the
> handle_slaves_guid_change() function during error handling even if
> the passed variable contained a null pointer.
>
> * Split a condition check for memory allocation failures.
>
> * Adjust jump targets according to the Linux coding style convention.
>
> * Delete an initialisation for these variables at the beginning
> which became unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
> drivers/infiniband/hw/mlx4/mad.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
> index cf33efce69d2..75b6522b3a8f 100644
> --- a/drivers/infiniband/hw/mlx4/mad.c
> +++ b/drivers/infiniband/hw/mlx4/mad.c
> @@ -1128,17 +1128,20 @@ static void propagate_pkey_ev(struct mlx4_ib_dev *dev, int port_num,
> static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
> u32 guid_tbl_blk_num, u32 change_bitmap)
> {
> - struct ib_smp *in_mad = NULL;
> - struct ib_smp *out_mad = NULL;
> + struct ib_smp *in_mad;
> + struct ib_smp *out_mad;
> u16 i;
>
> if (!mlx4_is_mfunc(dev->dev) || !mlx4_is_master(dev->dev))
> return;
>
> in_mad = kmalloc(sizeof *in_mad, GFP_KERNEL);
> + if (!in_mad)
> + return;
> +
> out_mad = kmalloc(sizeof *out_mad, GFP_KERNEL);
> - if (!in_mad || !out_mad)
> - goto out;
> + if (!out_mad)
> + goto free_in_mad;
>
> guid_tbl_blk_num *= 4;
>
> @@ -1171,8 +1174,9 @@ static void handle_slaves_guid_change(struct mlx4_ib_dev *dev, u8 port_num,
> }
>
> out:
> - kfree(in_mad);
> kfree(out_mad);
> +free_in_mad:
> + kfree(in_mad);
> }
>
> void handle_port_mgmt_change_event(struct work_struct *work)
> --
> 2.11.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Thanks,
Reviewed-by: Majd Dibbiny
<majd@...lanox.com>
Powered by blists - more mailing lists