@@ -2403,6 +2403,7 @@ int camtape_set_default(void *device)
24032403 */
24042404 if (ioctl (softc -> fd_sa , MTIOCPARAMSET , & sili_param ) == -1 ) {
24052405 msg = strdup ("Error returned from MTIOCPARAMSET ioctl to set the SILI bit" );
2406+ /* If strdup fails, msg is NULL; camtape_process_errors handles NULL gracefully */
24062407 rc = - EDEV_DRIVER_ERROR ;
24072408 camtape_process_errors (device , rc , msg , "set default parameter" , true);
24082409 goto bailout ;
@@ -2437,6 +2438,7 @@ int camtape_set_default(void *device)
24372438 eot_model = 1 ;
24382439 if (ioctl (softc -> fd_sa , MTIOCSETEOTMODEL , & eot_model ) == -1 ) {
24392440 msg = strdup ("Error returned from MTIOCSETEOTMODEL ioctl to set the EOT model to 1FM" );
2441+ /* If strdup fails, msg is NULL; camtape_process_errors handles NULL gracefully */
24402442 rc = - EDEV_DRIVER_ERROR ;
24412443 camtape_process_errors (device , rc , msg , "set default parameter" , true);
24422444 goto bailout ;
@@ -3946,6 +3948,7 @@ int camtape_set_lbp(void *device, bool enable)
39463948 entry = mt_status_entry_find (& mtinfo , tmpname );
39473949 if (entry == NULL ) {
39483950 msg = strdup ("Cannot find sa(4) protection.protection_supported parameter" );
3951+ /* If strdup fails, msg is NULL; camtape_process_errors handles NULL gracefully */
39493952 rc = - EDEV_INVALID_ARG ;
39503953 camtape_process_errors (device , rc , msg , "get lbp" , true);
39513954 goto bailout ;
@@ -3965,6 +3968,7 @@ int camtape_set_lbp(void *device, bool enable)
39653968 prot_entry = mt_status_entry_find (& mtinfo , MT_PROTECTION_NAME );
39663969 if (prot_entry == NULL ) {
39673970 msg = strdup ("Cannot find sa(4) protection node!" );
3971+ /* If strdup fails, msg is NULL; camtape_process_errors handles NULL gracefully */
39683972 rc = - EDEV_INVALID_ARG ;
39693973 camtape_process_errors (device , rc , msg , "get lbp" , true);
39703974 goto bailout ;
@@ -3998,6 +4002,7 @@ int camtape_set_lbp(void *device, bool enable)
39984002 entry = mt_entry_find (prot_entry , __DECONST (char * , protect_list [i ].name ));
39994003 if (entry == NULL ) {
40004004 msg = strdup ("Cannot find all protection information entries" );
4005+ /* If strdup fails, msg is NULL; camtape_process_errors handles NULL gracefully */
40014006 rc = - EDEV_INVALID_ARG ;
40024007 camtape_process_errors (device , rc , msg , "get lbp" , true);
40034008 goto bailout ;
@@ -4020,6 +4025,7 @@ int camtape_set_lbp(void *device, bool enable)
40204025 snprintf (tmpstr , sizeof (tmpstr ), "Error returned from MTIOCSETLIST ioctl to set "
40214026 "protection parameters: %s" , strerror (errno ));
40224027 msg = strdup (tmpstr );
4028+ /* If strdup fails, msg is NULL; camtape_process_errors handles NULL gracefully */
40234029 rc = - errno ;
40244030 camtape_process_errors (device , rc , msg , "get lbp" , true);
40254031 goto bailout ;
0 commit comments