Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl: Fix an error message

'rc' is known to be 0 here.
Initialize 'rc' with the expected error code before using it.

While at it, avoid the affectation of 'rc' in a 'if' to make things more
obvious and linux style.

Fixes: f204e0b8cedd ("cxl: Driver code for powernv PCIe based cards for userspace access")
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Link: https://lore.kernel.org/r/fa2b2c9c72335ab4c3d5e6a33415e7f020b1d51b.1620243401.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Christophe JAILLET and committed by
Greg Kroah-Hartman
da9db711 e4e05016

+3 -2
+3 -2
drivers/misc/cxl/file.c
··· 569 569 int rc; 570 570 571 571 cdev_init(cdev, fops); 572 - if ((rc = cdev_add(cdev, devt, 1))) { 572 + rc = cdev_add(cdev, devt, 1); 573 + if (rc) { 573 574 dev_err(&afu->dev, "Unable to add %s chardev: %i\n", desc, rc); 574 575 return rc; 575 576 } ··· 578 577 dev = device_create(cxl_class, &afu->dev, devt, afu, 579 578 "afu%i.%i%s", afu->adapter->adapter_num, afu->slice, postfix); 580 579 if (IS_ERR(dev)) { 581 - dev_err(&afu->dev, "Unable to create %s chardev in sysfs: %i\n", desc, rc); 582 580 rc = PTR_ERR(dev); 581 + dev_err(&afu->dev, "Unable to create %s chardev in sysfs: %i\n", desc, rc); 583 582 goto err; 584 583 } 585 584