Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932201AbbGHEXz (ORCPT ); Wed, 8 Jul 2015 00:23:55 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:50722 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751564AbbGHEXg (ORCPT ); Wed, 8 Jul 2015 00:23:36 -0400 X-AuditID: cbfee68d-f79106d00000728c-2b-559ca5c65e24 Date: Wed, 08 Jul 2015 04:23:34 +0000 (GMT) From: Maninder Singh Subject: Re: [PATCH 1/1] infiniband: Remove redundant NULL check before kfree To: Doug Ledford Cc: Sean Hefty , Or Gerlitz , David Miller , "roland@purestorage.com" , Matan Barak , Moni Shoua , "jackm@dev.mellanox.co.il" , Yishai Hadas , "eranbe@mellanox.com" , Ira Weiny , linux-rdma , linux-kernel , PANKAJ MISHRA Reply-to: maninder1.s@samsung.com MIME-version: 1.0 X-MTR: 20150708041407835@maninder1.s Msgkey: 20150708041407835@maninder1.s X-EPLocale: en_US.windows-1252 X-Priority: 3 X-EPWebmail-Msg-Type: personal X-EPWebmail-Reply-Demand: 0 X-EPApproval-Locale: X-EPHeader: ML X-MLAttribute: X-RootMTR: 20150708041407835@maninder1.s X-ParentMTR: X-ArchiveUser: X-CPGSPASS: N X-ConfirmMail: N,general Content-type: text/plain; charset=windows-1252 MIME-version: 1.0 Message-id: <1037392254.437811436329408244.JavaMail.weblogic@ep2mlwas06a> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRmVeSWpSXmKPExsWyRsSkTvfY0jmhBldbVSwu75rD5sDo8XmT XABjFJdNSmpOZllqkb5dAlfG6n3LmQpWcFY0P+tgb2Bs4exi5OQQElCTWLT3MVsXIweHhICJ xNQ3uSBhCQExiQv31gOFuYBKljJKtH8+wgqRMJE4O/cJM0TvHEaJ3bcLQWwWARWJ3ukTwGrY BPQlzu5dB1YjLOArsb9pNTPIfBEBDYktB8RBwswC21gk5h/IgRijKLH+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tsuLoGazyexZuFbFpj6XaeWM8Psur9l LlSvhMTWliesEL8oSkzpfsgOYRtIHFk0hxXVLxxAtqfEw5tMExhlZyHJzELSPQtJN7KaBYws qxhFUwuSC4qT0iuM9IoTc4tL89L1kvNzNzGCU9CzRTsY/523PsQowMGoxMP7IXJOqBBrYllx Ze4hRgkOZiUR3gR3oBBvSmJlVWpRfnxRaU5q8SFGU2CcTWSWEk3OB6bHvJJ4Q2MTc1NjUwsD Q3NzMyVx3v/nckOEBNITS1KzU1MLUotg+pg4OKUaGPcXXEh/uSehcqLGrMXa2xdp+BgufSJ/ 2CfU0ileT2LNP735Fd66vb92SvEI2ntNCFMT3euXrxTqcFv59Uw9mWsmGXPuiO5tbGV4myXv xfZEom/CgQUhK6LfLHzU5N71QVTklNaBlLKJLi25n++2ikbvzlEriecMm5psyNY4/biJ3O6y s2tuKrEUZyQaajEXFScCAH/v+nBXAwAA DLP-Filter: Pass X-CFilter-Loop: Reflected 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 base64 to 8bit by mail.home.local id t684O8vU020691 Content-Length: 992 Lines: 35 Hello, >> + for (i = 0; i < dev->caps.num_ports; i++) >> + kfree(dm[i]); >> goto out; >> } >> } >> -- >> 1.7.9.5 >> > >If you are going to change this, you might as well make it 100% correct: > >i?-; >while (i >= 0) > kfree(dm[i]); > >Then you don?t have to worry about whether kfree works on NULL, every item you free will be guaranteed to be non-NULL. Thanks for suggestion :) Sent new patch with described changes, I was thinking one more thing. In below code :- if (!ibdev->sriov.is_going_down) queue_work(ibdev->sriov.demux[i].ud_wq, &dm[i]->work); spin_unlock_irqrestore(&ibdev->sriov.going_down_lock, flags); } out: kfree(dm); return; dm is freed after queue_work, is it correct to free dm when other dm[i] are allocated ? i did not get it. Thanks Maninder ------------????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?