From patchwork Thu Dec 28 12:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 759801 Received: from mout.web.de (mout.web.de [212.227.17.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C409B6FD6; Thu, 28 Dec 2023 12:05:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="kCvCpeAv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1703765116; x=1704369916; i=markus.elfring@web.de; bh=cJQqD6vC6OovsIlVnJsS/+nszJU8beuDfrI1RA2WO5k=; h=X-UI-Sender-Class:Date:To:Cc:From:Subject; b=kCvCpeAvjnFFioX1WSSvuToAGgUBbmrqXmC2XYSGG8qaPAXOjLV7zKEpwxa59QWr eXvVjdoYHhur48csz82wkTw26WHVpXkdk1wLo8JJ6ARjsWHq27eyDyhwFdtcwFDYE eyh0hM8LubG1phOjo7w87gKkXCGWJGGBJ6TNhEbiCQSMDdVzB+v3K52VcqT2zpevK IbXePELkZagsw8T/CySKBroltU6vSuCbIzTpDsr1Ac8HOTPI9YlHYWCVzuGODPZss hzyqA0dTX8vYKq/UOgKI+GYyLAQD2xY7wEY/zMOEBW0gelMBDaIkGTACv6z+joeJd wvT56P+jmEAb7Vkq/g== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.85.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1M4KNf-1rIY9d2Ma1-000Wmj; Thu, 28 Dec 2023 13:05:16 +0100 Message-ID: Date: Thu, 28 Dec 2023 13:05:15 +0100 Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org, Hannes Reinecke , "James E. J. Bottomley" , "Martin K. Petersen" Content-Language: en-GB Cc: LKML From: Markus Elfring Subject: [PATCH] scsi: fcoe: Return directly after a failed kzalloc() in fcoe_sysfs_fcf_add() X-Provags-ID: V03:K1:n3oW30yzy361TbC4+2QAbRA0LJ/v3WPMXWZWSmvY8JpYpKGXJno ZbXXovZQz99Twcvyef0K4T1kjA0mU/+PB9Ax2EfvtfQYmWQ72jmD55Oo7w8Ja/k3p7jNkOx 0rhEnDSLbgRDNKLCn4E9WObD1Y/g162+QamJ73gSSJsdDEAL0C1alxH4wxmb6W4jQijteHD 0rHTUpGFHe2LQE+gaVHzg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:/rqUFD75ncM=;ZZr4t6L050dgCyjGKaZolwWcJC1 AC0UIpOhL1u/KwKhAMG4rkwkc62JvMdJAemPy6r0WrFfF2+DHL1H7zr9sjpmKsGgjwzIxv//2 UHwh+GlkV58XhJuLRO40hRTx/e4HSGhyP7jtRL4K4+ini0Ebg2YwUhUGcv9LmWGQQ/Ap+MZWU 8aOxIbQ5fK+HBbfLPg1bs7iJWrPM87POY4hb0KUo1tp4SCsBG15u7RJfu4LKyqP1oeobAZKAh 4pLoSOPUFdQelKN9DLrVVyd62M6nL/8sHrwa+0e7td0Xs/opEDhtwKCe/rwdlyA9RyHEk7VO5 TCJH/hhNOn6UoP+qO2+EBqToLqelZx9GvmOs+nrdAZxt0Oz+2WZVafCVx1tIsthnk/nDuCrjA kYsgaanFRAGQwtqJc6Pr5At6U9WkWhvOmSbXFDXdJWhylFpIoifSI2ql2ChruOFz4q71qjOG9 9PmQGiIDmcmYaluCetMvrJb1jH9yjRXUqihSt/7oRH7VH6hp/IkYG+lXnQ6eWVCfsGw1D3TvE abitNxwfPiTLS8VsADeb2NdLrlhWTlJD4+XCHhMJOSibxKZWG1RqC60W+B4JAZWM/caBHHVsb kBgXcjgzrN8rOZNU08JdW9HW8q4Jrxxho2qz+U0zwnWZlBMdDlmdaWbv24GBNPXdlV2QELfm5 Yf+up0THQwHh6IAbsKiu4jaIXRDKE8tcD/Q+flBWNpIXwvJB8Tv8hCzVeDrOcynP51M/r9aWU bQGyyhAgwEt+NHxTqA3W8rMBmZxZ3Drzu7e/YOziPq/mkdSISD4shfAT7yOnKWnlow3r2KG5F qYaWc7zp2QY2i3oKLSShqql01wS/DUSpLUTr8skoEffdAwlZzE5/w5uKXBavyBSrwmydZNagN F9k5r7x4M2Z5yL0nL63CqQO/fvW1fFFk2QVFso7kCqX2fJM5+vljKaMUku4cckOylIzzA3Rtj Pb7qpw== From: Markus Elfring Date: Thu, 28 Dec 2023 12:34:41 +0100 The kfree() function was called in one case by the fcoe_sysfs_fcf_add() function during error handling even if the passed variable contained a null pointer. This issue was detected by using the Coccinelle software. * Thus return directly after a call of the function “kzalloc” failed at the beginning. * Delete an initialisation for the variable “rc” which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/scsi/fcoe/fcoe_ctlr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.43.0 diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index 19eee108db02..df7c8f68596e 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c @@ -163,14 +163,14 @@ static int fcoe_sysfs_fcf_add(struct fcoe_fcf *new) struct fcoe_ctlr *fip = new->fip; struct fcoe_ctlr_device *ctlr_dev; struct fcoe_fcf_device *temp, *fcf_dev; - int rc = -ENOMEM; + int rc; LIBFCOE_FIP_DBG(fip, "New FCF fab %16.16llx mac %pM\n", new->fabric_name, new->fcf_mac); temp = kzalloc(sizeof(*temp), GFP_KERNEL); if (!temp) - goto out; + return -ENOMEM; temp->fabric_name = new->fabric_name; temp->switch_name = new->switch_name;