From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751470AbdBSRJK (ORCPT ); Sun, 19 Feb 2017 12:09:10 -0500 Received: from mail-eopbgr00069.outbound.protection.outlook.com ([40.107.0.69]:9965 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750844AbdBSRJI (ORCPT ); Sun, 19 Feb 2017 12:09:08 -0500 From: Majd Dibbiny To: SF Markus Elfring CC: "linux-rdma@vger.kernel.org" , Doug Ledford , Hal Rosenstock , "Leon Romanovsky" , Matan Barak , "Sean Hefty" , Yishai Hadas , LKML , "kernel-janitors@vger.kernel.org" Subject: Re: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() Thread-Topic: [PATCH 07/29] IB/mlx4: Split a condition check in handle_slaves_guid_change() Thread-Index: AQHSiilX2+e1+j/LZEqundHHFpIoMKFwkWut Date: Sun, 19 Feb 2017 17:09:03 +0000 Message-ID: References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net>,<951c0746-b88e-8ee7-78e8-5be2a53a2e43@users.sourceforge.net> In-Reply-To: <951c0746-b88e-8ee7-78e8-5be2a53a2e43@users.sourceforge.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=majd@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [46.121.82.152] x-ms-office365-filtering-correlation-id: b58cd80f-42e7-467d-b0d0-08d458ea01a3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:AM4PR0501MB1921; x-microsoft-exchange-diagnostics: 1;AM4PR0501MB1921;7:A1UgUgArbhubtqzl2WAhaRhIzAqVpTwSqDdLjZ2JGw14U/3VFZkRiD0zEDHXforYNKZ7gGcaSXeb5nQ5u+KOxxwoZP+vh5Sx4fiuvO46MEwEMIKyrDCNp00cEB4K//LG3BpFWeumtk7DEGWz8Gp8C/i9e+0aBJSdSLmtrBJJFR3yju3rlQlE6Se76/xQUzvtXM6gzb8R8JQHmXkwa7sPquBa+zb6DvDzp1lSpARPS1EB/obrWCY92waRcsLxO4PnHVmzkD+dv1ZR3dD/OabzjVgUp1nZuxgCB/lUKTKnMHkX+Ho764z2oLikWLLamhot0lyzY1/hApP1fhNrW2Jt+A== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(42262312472803); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(20161123558025)(6072148);SRVR:AM4PR0501MB1921;BCL:0;PCL:0;RULEID:;SRVR:AM4PR0501MB1921; x-forefront-prvs: 02234DBFF6 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39850400002)(39840400002)(39450400003)(39410400002)(199003)(189002)(377454003)(24454002)(7736002)(305945005)(966004)(105586002)(4326007)(2906002)(3660700001)(3280700002)(86362001)(229853002)(8676002)(6486002)(77096006)(6246003)(81156014)(33656002)(106356001)(81166006)(106116001)(8936002)(97736004)(2900100001)(6116002)(3846002)(102836003)(53936002)(92566002)(189998001)(68736007)(66066001)(25786008)(122556002)(110136004)(6506006)(36756003)(5660300001)(6306002)(54356999)(76176999)(83716003)(54906002)(99286003)(82746002)(38730400002)(2950100002)(6916009)(39060400002)(50986999)(101416001)(6512007)(6436002)(104396002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR0501MB1921;H:DB6PR0501MB2072.eurprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Feb 2017 17:09:03.7547 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0501MB1921 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id v1JH9ECh009194 > On Feb 18, 2017, at 10:55 PM, SF Markus Elfring wrote: > > From: Markus Elfring > 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 > --- > 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@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Thanks, Reviewed-by: Majd Dibbiny