[usb:usb-testing 43/55] drivers/usb/typec/anx7411.c:387 anx7411_register_partner() warn: passing zero to 'PTR_ERR'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
head:   c76d09da77d69d7f737540985912ad2bca654713
commit: fe6d8a9c8e6456f8e7ba6b4ee528460beaf65a71 [43/55] usb: typec: anx7411: Add Analogix PD ANX7411 support
config: xtensa-randconfig-m041-20220715 (https://download.01.org/0day-ci/archive/20220717/202207171059.zvoL5dcM-lkp@xxxxxxxxx/config)
compiler: xtensa-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

New smatch warnings:
drivers/usb/typec/anx7411.c:387 anx7411_register_partner() warn: passing zero to 'PTR_ERR'
drivers/usb/typec/anx7411.c:573 anx7411_typec_register_altmode() warn: passing a valid pointer to 'PTR_ERR'
drivers/usb/typec/anx7411.c:996 anx7411_register_i2c_dummy_clients() error: buffer overflow 'anx7411_i2c_addr' 4 <= 7
drivers/usb/typec/anx7411.c:1484 anx7411_i2c_probe() warn: missing error code 'ret'

Old smatch warnings:
drivers/usb/typec/anx7411.c:997 anx7411_register_i2c_dummy_clients() error: buffer overflow 'anx7411_i2c_addr' 4 <= 7

vim +/PTR_ERR +387 drivers/usb/typec/anx7411.c

fe6d8a9c8e6456 Xin Ji 2022-07-14  373  static int anx7411_register_partner(struct anx7411_data *ctx,
fe6d8a9c8e6456 Xin Ji 2022-07-14  374  				    int pd, int accessory)
fe6d8a9c8e6456 Xin Ji 2022-07-14  375  {
fe6d8a9c8e6456 Xin Ji 2022-07-14  376  	struct typec_partner_desc desc;
fe6d8a9c8e6456 Xin Ji 2022-07-14  377  
fe6d8a9c8e6456 Xin Ji 2022-07-14  378  	if (ctx->typec.partner)
fe6d8a9c8e6456 Xin Ji 2022-07-14  379  		return 0;
fe6d8a9c8e6456 Xin Ji 2022-07-14  380  
fe6d8a9c8e6456 Xin Ji 2022-07-14  381  	desc.usb_pd = pd;
fe6d8a9c8e6456 Xin Ji 2022-07-14  382  	desc.accessory = accessory;
fe6d8a9c8e6456 Xin Ji 2022-07-14  383  	desc.identity = NULL;
fe6d8a9c8e6456 Xin Ji 2022-07-14  384  	ctx->typec.partner = typec_register_partner(ctx->typec.port, &desc);
fe6d8a9c8e6456 Xin Ji 2022-07-14  385  	if (IS_ERR(ctx->typec.partner)) {
fe6d8a9c8e6456 Xin Ji 2022-07-14  386  		ctx->typec.partner = NULL;
fe6d8a9c8e6456 Xin Ji 2022-07-14 @387  		return PTR_ERR(ctx->typec.partner);

Set to NULL on previous line.

fe6d8a9c8e6456 Xin Ji 2022-07-14  388  	}
fe6d8a9c8e6456 Xin Ji 2022-07-14  389  
fe6d8a9c8e6456 Xin Ji 2022-07-14  390  	return 0;
fe6d8a9c8e6456 Xin Ji 2022-07-14  391  }

[ snip ]

fe6d8a9c8e6456 Xin Ji 2022-07-14  547  static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
fe6d8a9c8e6456 Xin Ji 2022-07-14  548  					  int svid, int vdo)
fe6d8a9c8e6456 Xin Ji 2022-07-14  549  {
fe6d8a9c8e6456 Xin Ji 2022-07-14  550  	struct device *dev = &ctx->spi_client->dev;
fe6d8a9c8e6456 Xin Ji 2022-07-14  551  	struct typec_altmode_desc desc;
fe6d8a9c8e6456 Xin Ji 2022-07-14  552  	int i;
fe6d8a9c8e6456 Xin Ji 2022-07-14  553  
fe6d8a9c8e6456 Xin Ji 2022-07-14  554  	desc.svid = svid;
fe6d8a9c8e6456 Xin Ji 2022-07-14  555  	desc.vdo = vdo;
fe6d8a9c8e6456 Xin Ji 2022-07-14  556  
fe6d8a9c8e6456 Xin Ji 2022-07-14  557  	for (i = 0; i < MAX_ALTMODE; i++)
fe6d8a9c8e6456 Xin Ji 2022-07-14  558  		if (!ctx->typec.amode[i])
fe6d8a9c8e6456 Xin Ji 2022-07-14  559  			break;
fe6d8a9c8e6456 Xin Ji 2022-07-14  560  
fe6d8a9c8e6456 Xin Ji 2022-07-14  561  	desc.mode = i + 1; /* start with 1 */
fe6d8a9c8e6456 Xin Ji 2022-07-14  562  
fe6d8a9c8e6456 Xin Ji 2022-07-14  563  	if (i >= MAX_ALTMODE) {
fe6d8a9c8e6456 Xin Ji 2022-07-14  564  		dev_err(dev, "no altmode space for registering\n");
fe6d8a9c8e6456 Xin Ji 2022-07-14  565  		return -ENOMEM;
fe6d8a9c8e6456 Xin Ji 2022-07-14  566  	}
fe6d8a9c8e6456 Xin Ji 2022-07-14  567  
fe6d8a9c8e6456 Xin Ji 2022-07-14  568  	ctx->typec.amode[i] = typec_partner_register_altmode(ctx->typec.partner,
fe6d8a9c8e6456 Xin Ji 2022-07-14  569  							     &desc);
fe6d8a9c8e6456 Xin Ji 2022-07-14  570  	if (IS_ERR(ctx->typec.amode[i])) {
fe6d8a9c8e6456 Xin Ji 2022-07-14  571  		dev_err(dev, "failed to register altmode\n");
fe6d8a9c8e6456 Xin Ji 2022-07-14  572  		ctx->typec.amode[i] = NULL;
fe6d8a9c8e6456 Xin Ji 2022-07-14 @573  		return PTR_ERR(ctx->typec.amode);

Wrong pointer.

fe6d8a9c8e6456 Xin Ji 2022-07-14  574  	}
fe6d8a9c8e6456 Xin Ji 2022-07-14  575  
fe6d8a9c8e6456 Xin Ji 2022-07-14  576  	return 0;
fe6d8a9c8e6456 Xin Ji 2022-07-14  577  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux